欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

cocos2dx spine骨骼动画

程序员文章站 2024-03-16 16:00:58
...
        #include <spine/spine-cocos2dx.h>
        #include "spine/spine.h"

        auto ske = resroot + "default.json";
        auto atl = resroot + "default.atlas";

        // 骨骼动画
        auto animi = spine::SkeletonAnimation::createWithFile(ske, atl);
        animi->setPosition(node->getPosition());
        node->getParent()->addChild(animi);
        animi->setAnimation(0, "animation", true);

        animi->setCompleteListener([animi](int trackIndex, int loopCount)
        {
            CCLOG("trackIndex: %d, loopCount: %d", trackIndex, loopCount);
            if (loopCount == 3)
            {
                // 只能异步移除
                animi->runAction(RemoveSelf::create());
            }
        });