Reputation: 225
In my cocos2d box2d app i have two bodies, the first has one fixture with a rectangle shape, the other has a complex shape. I have to calculate something when these bodies contact with each other. The problem is when they collide, the contact listener handles more than one fixture contact with the first body(because they can collide at the same time). I need to handle only one fixture contact every time, is there any way to reach this behavior?
Upvotes: 0
Views: 259
Reputation: 8526
Use the userData
property of the box2d bodies. When you process the collision, set a boolean to true and assign it to the user data, and then before you call world->update
, loop through all your bodies and clear this boolean value.
Upvotes: 2