USING_NS_CC_EXT;
//如发现编译连接错误,则需添加cocos-ext.h头文件目录E:\cocos2d\cocos2d-x-2.2.5\extensions(可是相对路径),以及lib库libExtensions.lib
之后在CCLayer继承者(例如class HelloWorld : public cocos2d::CCLayer)中,写入:
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Hero/Hero0.png","Hero/Hero0.plist","Hero/Hero.ExportJson");CCArmature* __armature = CCArmature::create("Hero");
__armature->setAnchorPoint(ccp(0.5f,0.5f));
__armature->getAnimation()->playByIndex(0);
__armature->setPosition(visibleSize.width/2 + origin.x,visibleSize.height/2 + origin.y);
addChild(__armature);
其中Hero/Hero0.png,Hero/Hero0.plist,"Hero/Hero.ExportJson“这三个资源由cocos studio创建导出,“Hero”为骨骼动画的骨骼名,也可在.ExportJson前面有个name字段内容。这是实验的是cocos studio自带的heroAnimation动画。效果如下: