i created a sprite and add physicsbody for it
when collsion detect, i can’t get sprite from physicsbody to remove it
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
siduko
#1
ben401
#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();
…
}