本文整理汇总了C++中cocos2d::PhysicsContact::getContactData方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsContact::getContactData方法的具体用法?C++ PhysicsContact::getContactData怎么用?C++ PhysicsContact::getContactData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d::PhysicsContact
的用法示例。
在下文中一共展示了PhysicsContact::getContactData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onContactBegin
bool SinglePlayerScene::onContactBegin(cocos2d::PhysicsContact &contact)
{
auto nodeA = contact.getShapeA()->getBody()->getNode();
auto nodeB = contact.getShapeB()->getBody()->getNode();
if (nodeA == _takyan || nodeB == _takyan) {
auto otherNode = nodeA == _takyan ? nodeB : nodeA;
if (otherNode == _floorBounds) {
if (!m_game->isPracticeMode())
{
m_game->setOver(true);
_kicker->getPhysicsBody()->setEnable(false);
PostGameDialog *dialog = PostGameDialog::createFromCCB();
dialog->setGameData(m_game);
Director::getInstance()->getRunningScene()->addChild(dialog, 1001);
}
}
else if (otherNode == _kicker)
{
if (!m_hitWhenKicked && !m_game->isOver())
{
m_hitWhenKicked = true;
m_game->addScore(m_scoreCanAcquire);
_labelScore->setString(StringUtils::format("%d", m_game->getScore()));
m_game->addHits(1);
std::string remarks;
Color4B color;
if (m_scoreCanAcquire == 1)
{
remarks = "Good";
color = Color4B(64, 64, 64, 255);
}
else if (m_scoreCanAcquire == 2)
{
remarks = "Great!";
color = Color4B::GRAY;
}
else if (m_scoreCanAcquire == 3)
{
remarks = "Perfect!";
color = Color4B::WHITE;
}
if (remarks.size() > 0)
{
std::string fontName = _labelScore->getTTFConfig().fontFilePath;
Label *remarksLabel = Label::createWithTTF(remarks, fontName, 12.0f, _labelScore->getDimensions()); //createWithSystemFont(remarks, fontName, 12.0f, _scoreLabel->getDimensions());
remarksLabel->setPosition(contact.getContactData()->points[0]);
remarksLabel->setTextColor(color);
remarksLabel->setHorizontalAlignment(TextHAlignment::CENTER);
remarksLabel->setVerticalAlignment(TextVAlignment::CENTER);
remarksLabel->enableOutline(Color4B::BLACK, 2);
this->addChild(remarksLabel, 10);
remarksLabel->runAction(Sequence::create(MoveBy::create(1.5f, Vec2(0, remarksLabel->getContentSize().height)), FadeOut::create(2.0f), CallFuncN::create([&](Node* node) {
node->removeFromParent();
}), NULL));
}
}
return !m_game->isOver();
}
else
{
}
}
return true;
}