0
votes

I have a simple animation in Cocos2d Chipmunk with the tasks:

  • One round shaped sprite situated in the center of the screen, rigid body type. Center of gravity needs to be located in center of this sprite.
  • From different sides of screen (spontaneously and beyond screen size) other rigid round sprites must fall into central sprite to fill visible screen space.
  • Sprites should not overlap one another.

So the questions are:

  1. How to reassign the vector of gravity to the center of the screen?
  2. How to implement collision detection between rigid body types in Cocos2d Chipmunk?

Thanks, colleagues!

1

1 Answers

1
votes
  1. You can't set a center for the gravity. You can only set a direction (the same for all objects). It's possible to create an effect you describe, but you'll have to do the work yourself. In every frame you have to set a force or apply an impulse on every body in the direction of your gravity. And the "regular" chipmunk gravity should be (0, 0).

  2. See this tutorial about collision detection.