当小鸟与得分线碰撞时,它会将小鸟停滞一会儿。

这是我的源代码

auto scoreNode = Node::create();
scoreNode->setPosition(topPipe->getContentSize().width / 2, 0);
scoreNode->setContentSize(Size(1, winSize.height));
scoreNode->setAnchorPoint(Point(0, 0));
scoreNode->setVisible(false);
this->addChild(scoreNode);

auto scoreBody = PhysicsBody::createBox(scoreNode->getContentSize());
scoreBody->setDynamic(false);
scoreBody->setCollisionBitmask(POINT_COLLISION_BITMASK);
scoreBody->setContactTestBitmask(true);
scoreNode->setPhysicsBody(scoreBody);

auto birdBody = PhysicsBody::createCircle(this->getContentSize().width / 2);
birdBody->setCollisionBitmask(HERO_COLLISION_BITMASK);
birdBody->setContactTestBitmask(true);
birdBody->setDynamic(true);
birdBody->setGravityEnable(true);
birdBody->setMass(10);
birdBody->setRotationEnable(true);


我希望那只小鸟在不停顿的情况下与得分线联系。我该如何实现?

我正在使用Cocos2d-x v3

最佳答案

终于我找出了问题所在。

scoreBody->setCollisionBitmask(false); // set the collision bit mask to false to disable it
scoreBody->setContactTestBitmask(true); // detect by the contact instead

09-06 00:38