本文整理汇总了C++中ActionTimeline::play方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionTimeline::play方法的具体用法?C++ ActionTimeline::play怎么用?C++ ActionTimeline::play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionTimeline
的用法示例。
在下文中一共展示了ActionTimeline::play方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: triggerActionTimeline
void MainScene::triggerActionTimeline(string animationName, bool loop)
{
// we pass "MainScene.csb" to the constructor
// so this ActionTimeline will be able to play any of the animations
// that we've created in MainScene.csd
ActionTimeline* timeline = CSLoader::createTimeline("MainScene.csb");
ERROR_HANDLING(timeline);
//this->stopAllActions(); // cancel any currently running actions on MainScene
this->runAction(timeline); // we tell MainScene to run the timeline
timeline->play(animationName, loop);
}
示例3: onEnter
// TestTimelineAnimationList
void TestTimelineAnimationList::onEnter()
{
ActionTimelineBaseTest::onEnter();
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
cocostudio::timeline::AnimationInfo standinfo("stand", 0, 40);
cocostudio::timeline::AnimationInfo walkinfo("walk", 41, 81);
action->addAnimationInfo(standinfo);
action->addAnimationInfo(walkinfo);
node->runAction(action);
action->play("walk", true);
node->setScale(0.2f);
node->setPosition(150,100);
addChild(node);
}
示例4: 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++;
}
});
}