Cocos2d-x的骨骼动画Spine和Armature

cocos2d-x中骨骼动画常用的有2种,spine和armature


Spine的基本用法

    //骨骼动画Spine,需要包含Spine/spine-cocos2dx.h头文件,命名空间spine
    auto skeleton=SkeletonAnimation::createWithFile("spine/spineboy.json","spine/spineboy.atlas");//加载文件
    skeleton->setAnimation(0,"walk",false);//运行骨骼动画,参数:(什么意思?,动作名,是否循环播放)
    skeleton->setPosition(500,0);
    skeleton->setScale(0.5f);//设置大小
    skeleton->setTimeScale(0.5f);//设置运行速度
    skeleton->setMix("walk","run",1.0f);//设置动画平缓切换用时
    skeleton->addAnimation(0,true);//在之前动作做完之后,添加一个动作
    skeleton->setDebugBonesEnabled(true);//显示骨头
    this->addChild(skeleton);


Armature的基本用法

    //骨骼动画armature,需要包含cocostudio/CocoStudio.h头文件,命名空间cocostudio
    //加载动作资源,可以用异步加载,参数有点怪
    ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/Cowboy0.png","armature/Cowboy0.plist","armature/Cowboy.ExportJson");
    auto am=Armature::create("Cowboy");//创建骨骼动画
    am->setScale(0.6f);
    am->getAnimation()->setSpeedScale(0.5f);//设置播放速度
    am->getAnimation()->playWithIndex(0);//播放索引为0的动作
    am->setPosition(500,300);
    this->addChild(am);

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...