温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

cocos2d-x 动画播放

发布时间:2020-07-19 11:35:57 来源:网络 阅读:475 作者:VincentTung 栏目:游戏开发
与动画相关的类   效果展示 TestCpp->ActionTest
CCAnimation
CCAnimate
CCAnimationCache
执行动画的三步骤
1.根据文件创建Animation
   --(1)多张图片
   --(2)一张合成图片 plist
2.根据Animation创建Animate
3.执行Animate
//1.多张分的的图片
    // Manual animation
    //
    CCAnimation* animation = CCAnimation::create();
    for( int i=1;i<15;i++)
    {
        char szName[100] = {0};
        sprintf(szName, "Images/grossini_dance_%02d.png", i);
        animation->addSpriteFrameWithFileName(szName);
    }
    // should last 2.8 seconds. And there are 14 frames.
    animation->setDelayPerUnit(2.8f / 14.0f);
    animation->setRestoreOriginalFrame(true);
    CCAnimate* action = CCAnimate::create(animation);
    m_grossini->runAction(CCSequence::create(action, action->reverse(), NULL));
    //2.plist图片加载
    // File animation
    //
    // With 2 loops and reverse
 //AnimationCache预加载的使用
    CCAnimationCache *cache = CCAnimationCache::sharedAnimationCache();
    cache->addAnimationsWithFile("animations/animations-2.plist");
    CCAnimation *animation2 = cache->animationByName("dance_1");
    CCAnimate* action2 = CCAnimate::create(animation2);
    m_tamara->runAction(CCSequence::create(action2, action2->reverse(), NULL));
AnimationCache预加载的使用

//学习如何使用工具

拼图工具:

TexturePacker

Zwoptex

骨骼动画:

cocosbuilder

cocostudio

红孩儿


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI