大佬教程收集整理的这篇文章主要介绍了Cocos2dx v3.2骨骼动画加载学习,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
一、使用Cocos studio之前需要导入GUI、Extensions、Cocosstudio的类库
右击解决方案选择添加现有项目添加这三个库文件导入成功效果如下
二、选择工程右键选择 属性-》通用属性-》添加新引用
勾选所添加库的lib选项效果图如下,完成后效果如下
三、添加附加包含目录
右键选择项目属性-》配置属性-》c/c++-》附加包含目录-》下拉按钮选择编辑
在附加包含目录中添加
$(ENGIneRoot) extensions需要
$(ENGIneRoot)cocos\editor-support\ cocosstudio需要
$(ENGIneRoot)cocos\editor-support\cocostudio cocosstudio需要
效果图
四、代码实现
在Cocos2d-x程序中使用COcos studio动画首先需要包含相关头文件,如下:
五、主要api及使用方法
骨骼动画学习
3.0
ArmatureDataManager::geTinstance()->addArmatureFileInfo("zhujue.ExportJson");
armature = Armature::create("zhujue");
armature->getAnimation()->playWithIndex(0);
this->addChild(armaturE);
骨骼动画翻转armature->setScaleX(-1);加载到节点上翻转节点没有效果
1.异步加载
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfoAsync("armature/Heroanimation.ExportJson",this,schedule_SELEctor(TestAsynchronousLoading::dataLoaded));
2.直接加载
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("armature/bear.ExportJson");
3.移除加载
CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo("armature/bear.ExportJson");
4.骨骼动画常用操作
cocos2d::extension::CCArmature *armature = NULL;
armature = cocos2d::extension::CCArmature::create("Dragon");
int num = armature->getAnimation()->getMovementCount(); //得到动作数量
armature->getAnimation()->playWithIndex(0); //动作序号(上面的num)
std::vector<int> indexes(index,index+3);
armature->getAnimation()->playWithIndexes(indexes); //多动作连续播放
std::string str = armature->getAnimation()->getCurrentMovementID(); //得到当前动作名
armature->getAnimation()->play("Fire",10); //动画名
armature->getAnimation()->setSpeedScale(0.4f); //速度
armature->getAnimation()->setMovementEventCallFunc(this,movementEvent_SELEctor(TestAnimationEvent::animationEvent)); //关联动画事件
armature->setPosition(VisibleRect::center().x,VisibleRect::center().y * 0.3f);
armature->setScale(0.6f);
addChild(armaturE);
cocos2d::extension::CCBone *bone = cocos2d::extension::CCBone::create("p1");
bone->addDisplay(p1,0);
bone->changeDisplayWithIndex(0,truE);
bone->setIgnoreMovementBoneData(true);
bone->setZOrder(100);
bone->setScale(1.2f);
armature->addBone(bone,"bady-a3");
std::string weapon[] = {"weapon_f-sword.png","weapon_f-sword2.png","weapon_f-sword3.png","weapon_f-sword4.png","weapon_f-sword5.png","weapon_f-knife.png","weapon_f-hAMMer.png"};
cocos2d::extension::CCSkin *skin = CCSkin::createWithSpriteFramename(weapon[i].c_str());
armature->getBone("weapon")->addDisplay(skin,i); //添加显示
armature->getBone("weapon")->changeDisplayWithIndex(displayIndex,truE); //替换显示
5.cocos2d::extension::CCBatchNode 批量节点渲染
以上是大佬教程为你收集整理的Cocos2dx v3.2骨骼动画加载学习全部内容,希望文章能够帮你解决Cocos2dx v3.2骨骼动画加载学习所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。