[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Move static shapes, or another method?

Move static shapes, or another method?

Official forum for the .

Move static shapes, or another method?

Postby mrTortex » Mon Jul 26, 2010 12:09 pm

Hello.

Using Cocos2D and Chipmunk together, I have a parallax node with three levels. I want to add a collision object to the front most level, but it must start off screen then move in. I've heard using a static shape, moving then re-hashing every frame is the bad way to do it, and I vaguely understand why. Currently however, this is the only way I can think to do it. Can anyone think of a better alternative, as at some point I'm going to need a fair amount more collision objects and I'd like to be as efficient as possible :)

Thanks.
mrTortex
 
Posts: 51
Joined: Sat Jul 24, 2010 9:38 am

Re: Move static shapes, or another method?

Postby slembcke » Mon Jul 26, 2010 12:39 pm

If you have a static shape that you are rehashing every frame, you should just add it as a normal shape. Static shapes are just an optimization for the collision detection so they don't have to be updated every frame. If you are doing that anyway, then you are just undoing the optimization in a very expensive way.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move static shapes, or another method?

Postby mrTortex » Mon Jul 26, 2010 1:07 pm

OK, thought as much. So, I guess I give the collision object a huge mass or something so it doesn't get effected by the collision?

But, wont my shape be effect by gravity?

I have a feeling dynamic shapes are not would you'd call 'normal shapes', I'll go read.
mrTortex
 
Posts: 51
Joined: Sat Jul 24, 2010 9:38 am

Re: Move static shapes, or another method?

Postby slembcke » Mon Jul 26, 2010 3:07 pm

Collision hapes aren't affected by gravity, the rigid bodies the are attached to are. Bodies added to the space are simulated (and fall under gravity). Adding a shape to the space does not automatically add the body as well.

You should set the mass and moment of inertia of your externally controlled body to INFINITY.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move static shapes, or another method?

Postby mobilebros » Mon Jul 26, 2010 9:35 pm

mobilebros
 
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am

Re: Move static shapes, or another method?

Postby mrTortex » Tue Jul 27, 2010 12:29 pm

Hello.

I am indeed, thanks for spotting my post and offering this. :) That's another pint I owe you.
mrTortex
 
Posts: 51
Joined: Sat Jul 24, 2010 9:38 am

Re: Move static shapes, or another method?

Postby mrTortex » Tue Jul 27, 2010 1:07 pm

Any idea why when I add Chipmunk shapes to the parallax node it crashes? Compiles fine, but then just fails.

I'll post code later if I can, code machine has no net access. :(
mrTortex
 
Posts: 51
Joined: Sat Jul 24, 2010 9:38 am

Re: Move static shapes, or another method?

Postby slembcke » Tue Jul 27, 2010 1:08 pm

Did you try running it in the debugger to find out what line it crashes on and why?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move static shapes, or another method?

Postby mrTortex » Tue Jul 27, 2010 1:20 pm

Yep, nothing jumps out. It doesn't actually crash as such, it just hangs the device. In the simulator the level doesn't load, I just get a black screen. When I quit, it quits as it would with everything working. My code has grown to be messy as hell, let me have a tidy up and see where that gets me.
mrTortex
 
Posts: 51
Joined: Sat Jul 24, 2010 9:38 am

Re: Move static shapes, or another method?

Postby mrTortex » Tue Jul 27, 2010 1:41 pm

mrTortex
 
Posts: 51
Joined: Sat Jul 24, 2010 9:38 am

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron