Search code examples
iphonecocos2d-iphonegame-enginegame-physicschipmunk

Cocos2d Chipmunk gravity property


I need to imitate radial (planetary-) gravity when all dynamic bodies in the space are attracted to the static body situated in the center of the screen. I set

space->gravity = ccp(0, 0);

I create dynamic bodies with calling their creating methods in -init, which will fall on this central body from other sides like here http://www.youtube.com/watch?v=2BxkbXfEWg4&feature=player_embedded from 0:12.

Questions:

  1. how can I set gravity vector individually for every single object? I plan to real-time reassign gravity vector, based on objects coordinates changes.
  2. what actually have property of gravity: sprite, body or shape?
  3. is it a more simple way to realize this effect?

Solution

  • Scott Lembcke gives the answer on Cocos2d forum here:

    http://www.cocos2d-iphone.org/forum/topic/35621?replies=4#post-171187