zoukankan      html  css  js  c++  java
  • cocos进阶教程(5)各种动画使用心得

    Node类 不解释

    ActionTimeline类是一个3.0时代的动画类,

    案例一

    //建立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类

    案例一:

    //异步加载方案
    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);
  • 相关阅读:
    swagger多个分组代码展示
    rabbitMQ基本概念
    谈谈微信支付曝出的漏洞
    谈谈离职和跳槽
    一个著名的任务调度系统是怎么设计的?
    BAT等公司必问的8道Java经典面试题,你都会了吗?
    从世界杯竞猜骗局谈二分法
    Spring4+Spring MVC+MyBatis整合思路
    十张图让你了解阿里公司架构设计的发展变化史
    一位00后程序员的成长历程
  • 原文地址:https://www.cnblogs.com/damowang/p/4997474.html
Copyright © 2011-2022 走看看