本文整理汇总了C++中ActionTimeline::setLastFrameCallFunc方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionTimeline::setLastFrameCallFunc方法的具体用法?C++ ActionTimeline::setLastFrameCallFunc怎么用?C++ ActionTimeline::setLastFrameCallFunc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionTimeline
的用法示例。
在下文中一共展示了ActionTimeline::setLastFrameCallFunc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: animateHitPiece
void MainScene::animateHitPiece(Side obstacleSide)
{
Piece* flyingPiece = dynamic_cast<Piece*>(CSLoader::createNode("Piece.csb"));
ActionTimeline* pieceTimeline = CSLoader::createTimeline("Piece.csb");
flyingPiece->setObstacleSide(obstacleSide);
flyingPiece->setPosition(this->flyingPiecePosition);
this->addChild(flyingPiece);
this->runAction(pieceTimeline);
switch (this->character->getSide()) {
case Side::Left:
pieceTimeline->play("moveRight", false);
break;
case Side::Right:
pieceTimeline->play("moveLeft", false);
break;
default:
break;
}
// on the last frame of the animation, remove the piece from the scene
pieceTimeline->setLastFrameCallFunc([this, &flyingPiece]() {
this->removeChild(flyingPiece);
});
}
示例2: createSkin
void ScenePlot::createSkin()
{
auto skin = CSLoader::createNode(RES_MODULES_PLOT_SCENE_PLOT_CSB);
addChild(skin);
auto layoutBg = (Layout *)skin->getChildByName("layoutBg");
layoutBg->addTouchEventListener([=](Ref *ref, Widget::TouchEventType type)
{
if (type == Widget::TouchEventType::ENDED)
{
ActionTimeline *actionTimeline = (ActionTimeline *)skin->getActionByTag(skin->getTag());
if (actionTimeline == nullptr)
{
actionTimeline = CSLoader::createTimeline(RES_MODULES_PLOT_SCENE_PLOT_CSB);
skin->runAction(actionTimeline);
}
auto animationName = "animation" + Value(_countClickCurr).asString();
auto isAnimationInfoExists = actionTimeline->IsAnimationInfoExists(animationName);
if (!isAnimationInfoExists)
{
ManagerData::getInstance()->setSaveFileExist();
ManagerUI::getInstance()->replaceScene(TypeScene::MAIN);
return;
}
if (_isPlaying)
{
return;
}
_isPlaying = true;
actionTimeline->play(animationName, false);
actionTimeline->setLastFrameCallFunc([=]()
{
_isPlaying = false;
});
_countClickCurr++;
}
});
}