Cocos2d-x的骨骼动画Spine和Armature
2015-07-13 14:00
537 查看
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, "run", 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);
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, "run", 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);
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- 关于指针的一些事情
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- Lua中调用C++函数示例
- Lua教程(一):在C++中嵌入Lua脚本
- Lua教程(二):C++和Lua相互传递数据示例
- C++联合体转换成C#结构的实现方法
- C++编写简单的打靶游戏
- C++ 自定义控件的移植问题
- C++变位词问题分析
- C/C++数据对齐详细解析
- C++基于栈实现铁轨问题
- C++中引用的使用总结
- 使用Lua来扩展C++程序的方法
- C++中调用Lua函数实例
- Lua和C++的通信流程代码实例
- C与C++之间相互调用实例方法讲解
- C++ Custom Control控件向父窗体发送对应的消息
- C++中拷贝构造函数的应用详解