예제 #1
0
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
0
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
0
// 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
0
파일: ScenePlot.cpp 프로젝트: capricemz/LL
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++;
		}
	});
}