I am adding a b2BodyDef to my CCScene like so:
b2BodyDef platformBodyDef;
platformBodyDef.type = b2_dynamicBody;
platformBodyDef.position.Set(40, 495);
platformBodyDef.userData = platforms;
_body = _world->CreateBody(&platformBodyDef);
I know I am supposed to use contact listeners but I am new to Box2D and this is like another language to me so how would I code it to see if one of the CCSprites in my CCScene collides with this b2BodyDef? This b2BodyDef will be animating but I am not worrying about that right now.
Does anyone know how I can do this?
Thanks!
There is a very good tutorial describing how to do this here
Basically what you do is create a contactListener which listens for collisions between bodies. Make sure your sprites are tagged, and then in the contact listener you load up the spriteData of the two objects that collided. By checking the tags you can identify the sprites that collided.
From there you can do pretty much anything, as you have a reference to the sprite, the body and the world. For example, as in the aforementioned example, removing the brick.