I'm a newbie of Cocos2d-x 3.2 Physic Engine (as Cocos2d-x said, this engine is base on Chipmuk). I made a sample "Egg shooting" game of Popcap. When detecting contact of 2 eggs, I met a problem, dynamic 'egg' seems sink to static 'egg' when contact event is throwed. I set for eggs:
- Mass: 10.f
- PHYSICSSHAPE_MATERIAL_DEFAULT
- applyImpulse about (0,900)
This is image:
Detect contact ball event
auto contactBallListener = EventListenerPhysicsContact::create();
contactBallListener->onContactBegin = CC_CALLBACK_1(IngameScene::onContactBallsBegin, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(contactBallListener, this);
.....
bool IngameScene::onContactBallsBegin(PhysicsContact& contact)
{
auto objA = contact.getShapeA()->getBody()->getNode();
auto objB = contact.getShapeB()->getBody()->getNode();
}
Physical Setup
if (group == BallGroupTarget) {
//Green ball
body->setCategoryBitmask(0xFFFFFFF0);
body->setContactTestBitmask(0x0000000F);
body->setCollisionBitmask(0xFFFFFFFF);
} else if (group == BallGroupShooting){
//Pink ball
body->setContactTestBitmask(0xFFFFFFFF);
body->setGravityEnable(false);
}
Can you help me to solve this problem?
Thanks a lot!