auto contactListener = EventListenerPhysicsContact::create();
**contactListener->onContactBegin = CC_CALLBACK_2(StageScene::onContactBegin);**
ERROR: No viable overloaded ‘=’
Why i cannot use it more? Can anyone help me?
#2
auto enemyBody = PhysicsBody::createBox(Size(enemy->getWidth(), enemy->getHeight()));
enemyBody->setRotationEnable(false);
enemyBody->setDynamic(false);
enemyBody->setGravityEnable(false);
enemy->setPhysicsBody(enemyBody);
Before update, with this code i move my objects manually and it generate Physic contact but is not affected by gravity. After update every object is going down What i do to continue moving it manually and generate contact event when collide using cocos2d-x RC v3 ?
You need to setContactTestBitmask for the body, because the listener only receive the contact event you want to receive. It ignore all the contact event by default.
The problem #1 is solved, but only if i set dynamic = true.
But im using only collision from physic, i dont want that the objects is affected by gravity. Im trying it:
auto coinBody = PhysicsBody::createBox(Size(coin->getWidth(), coin->getHeight()));
coinBody->setRotationEnable(false);
coinBody->setDynamic(false);
coinBody->setGravityEnable(false);
coinBody->setContactTestBitmask(0xFFFFFFFF);
coin->setPhysicsBody(coinBody);
But with “coinBody->setDynamic(false);” no collision is detected, but the COIN position is updated manually(only position X), and when i set “coinBody->setDynamic(true);” the COIN if affected by gravity (but i set the gravity enable = false) and generate collision.
I cannot create a static object, that i update it manually and is not affected by gravity and generate collision event?