对于新手朋友不知道如何调用cocos Studio生成的动画我将代码公布出来,大家可以参考学习一下,有什么好的方法欢迎一起交流。
代码如下:
调用骨骼动画:
//加载导出的文件
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("animations/hero.png", "animations/hero.plist", "animations/hero.ExportJson");//创建对象
CCArmature* armature = CCArmature::create( "Hero" );
armature->setPosition(ccp(winSize.width/2, winSize.height/2));
armature->setScale(0.4);
//调用动画
armature->getAnimation()->playWithIndex(0);
this->addChild(armature, 0, 333);
=====================================================
需要包含头文件:
#include "cocos-ext.h"
using namespace cocos2d::extension;
VS项目属性中添加对 libExtension.lib 库的引用;
=====================================================
调用序列帧动画:
//加载导出的三个文件
CCArmatureDataManager ::sharedArmatureDataManager()->addArmatureFileInfo( "animations/frameAnimate0.png", "animations/frameAnimate0.plist" ,"animations/frameAnimate.ExportJson" );
//创建对象
cocos2d::extension:: CCArmature * armature;
armature = CCArmature ::create("frameAnimate" );
armature->setPosition(ccp(winSize.width/2, winSize.height/2));
//调用动画
armature->getAnimation()->playWithIndex(0);
//添加到父节点
this->addChild(armature);
=====================================================
需要包含头文件:
#include "cocos-ext.h"
using namespace cocos2d::extension;
VS项目属性中添加对 libExtension.lib 库的引用;
=====================================================