cocos進階教程(5)各類動畫使用心得

Node類 不解釋node

 

ActionTimeline類是一個3.0時代的動畫類,api

案例一異步

//創建node方案一
Data data = FileUtils::getInstance()->getDataFromFile("ActionTimeline/DemoPlayer.csb"); Node* node = CSLoader::createNode(data);
//創建node方案二
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
ActionTimeline* action = CSLoader::createTimeline(data, "ActionTimeline/DemoPlayer.csb"); node->runAction(action); action->gotoFrameAndPlay(0); node->setScale(0.2f); node->setPosition(VisibleRect::center()); addChild(node);

 

案例二動畫

    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);

 

Armature,ArmatureAnimation,ProcessBase這個是傳統的幀動畫使用的api類this

案例一:spa

//異步加載方案
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/testEasing.ExportJson", this, CC_SCHEDULE_SELECTOR(TestAsynchronousLoading::dataLoaded)); 
//同步加載方案   
ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/bear.ExportJson");

Armature *armature = Armature::create("bear");
//按動畫索引播放
armature->getAnimation()->playWithIndex(0);
//按動畫名稱播放
armature->getAnimation()->play("fire")
armature->setPosition(VisibleRect::center().x, VisibleRect::center().y);
addChild(armature);
相關文章
相關標籤/搜索