bool PFMPlayer::onContactBegin(cocos2d::PhysicsContact &contact) { if(contact.getShapeA()->getBody() == getPhysicsBody() || contact.getShapeB()->getBody() == getPhysicsBody()) { PhysicsBody* other = contact.getShapeA()->getBody() == getPhysicsBody()?contact.getShapeB()->getBody() : contact.getShapeA()->getBody(); switch (other->getTag()) { case PFMPhysicsBodyTypeEnemyBullet: { PFMBullet* bullet = dynamic_cast<PFMBullet*>(other->getNode()); if(bullet != NULL) { health -= bullet->damage; } other->getOwner()->removeFromParentAndCleanup(true); break; } case PFMPhysicsBodyTypeEnemy: other->getOwner()->removeFromParentAndCleanup(true); break; default: break; } } return true; }