当前位置: 首页>>代码示例>>C++>>正文


C++ ActionTimeline::setLastFrameCallFunc方法代码示例

本文整理汇总了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);
    });
    
}
开发者ID:adizdar,项目名称:cocosGameDemo,代码行数:28,代码来源:MainScene.cpp

示例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++;
		}
	});
}
开发者ID:capricemz,项目名称:LL,代码行数:43,代码来源:ScenePlot.cpp


注:本文中的ActionTimeline::setLastFrameCallFunc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。