How to get sprite to remove when collision detect with chipmuck physic

How to get sprite to remove when collision detect with chipmuck physic
0

#1

i created a sprite and add physicsbody for it
when collsion detect, i can’t get sprite from physicsbody to remove it


#2

The collision detect function you registered has a PhysicsContact parameter. From it, you can retrieve the 2 sprites that are colliding, and do whatever you want on them:

bool HelloWorld::onContactBegin(PhysicsContact &contact)
{
Sprite * spriteA = (Sprite *) contact.getShapeA()->getBody()->getNode();
Sprite * spriteB = (Sprite *) contact.getShapeB()->getBody()->getNode();


}


#3

Do you know how to get the Sprite from Body in Cocos2D JS using Chipmunk physics?