【CocoStudio 系列之一】 序列帧动画、骨骼动画、在Cocos2dx中引用动画

1 CocoStudio 简介

CocoStudio 是由 Cocos2d-x 官方推出的一个专门针对 Cocos2d-x 游戏开发的免费工具集,目前正在开发阶段,且日益完善之中!既是工具集,当然集成了现有各零零散散工具的功能,并且不断扩充,包含动画编辑器,UI编辑器,场景编辑器和数据编辑器。具体内容及其特性欢迎访问 CocoStudio 官网 http://cocostudio.org/ 。在这里,我们通过动画编辑器来快速体验一下 CocoStudio 为我们开发带来的便捷~

2 环境搭建与配置

本文章所使用的系统环境为 win7 系统,CocoStudio-0.2.0 版本。

在当前最新稳定版 cocos2d-x-3.0alpha1 的 TestCpp 中已经有例子展示了一些相关骨骼动画的效果。

3 序列帧动画的创建步骤

帧动画,顾名思义!就是将一张张设计好的图片,依次展示出来,就像放胶片电影一样,多帧组成动画效果。不多介绍了,直接看 CocoStudio 的使用方法。

  1. 打开 CocoStudio 启动动画编辑器
  2. 点击文件新建项目,并确定
  3. 在资源窗口选择添加资源,序列帧原图(这里不支持使用plist作为资源,但可以导出plist)
  4. 选择第一帧图片,拖进“渲染窗口”,选择工具栏第三项,居中显示。(居中可选操作) (图片格式必须为PNG,否则CocoStudio不加载图片)

  5. 我们看见在“对象结构”视图中多出一个层,这就是序列帧动画层,在资源视图多选文件(除首帧之外),之后拖动到“对象结构”视图中刚才那个层之上,我们将能够看见“关键帧”视图的变化,当前帧根据图片数量自动变化,注意“对象结构”视图中鼠标的位置。 

  6. 点击“关键帧”视图“播放”即可播放,也可循环播放动画 

  7. 保存项目后,可以导出大图,自动打包资源图片,在本例中生成了 “CsAnim.ExportJson”,”CsAnim0.plist” 和 “CsAnim0.png” 三个文件,然后我们就能拿着这三个文件在 Cocos2d-x 中使用了。

4 如何在 Cocos2d-x 中运行其动画

上面我们生成了一些文件,动画的资源文件,此时我们需要在 Cocos2d-x 中加载这些资源,并运行之,我们将以上文件放在项目 “Resources” 的 “Export” 目录之中。 然后使用如下关键代码,创建动画。例子代码可以从这里下载学习使用:http://www.cocostudio.org/detail.php?id=4062

<ol class="linenums" style="margin: 0px 0px 0px 40px; padding: 0px 0px 0px 27px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; line-height: 1.5em; font-family: inherit; list-style: none;"><li value="1" class="L0" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="com" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(136, 0, 0);">// 加载资源文件 png 图片,plist 文件和 ExportJson 动画文件,一般而言可以在场景运行之初加载此资源</span></li><li value="1" class="L0" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span style="color: rgb(136, 0, 0);">//在<span style="font-size: 13.63636302947998px; line-height: 27.99715805053711px; white-space: pre; background-color: rgb(238, 238, 238);">cocoStudio生成图片资源时,因为图片过大导致图片分成了几张,我们只需将png/plist变换下即可正常引用</span></span></li><li class="L1" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="typ" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 0, 102);">ArmatureDataManager</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">::</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">sharedArmatureDataManager</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">()-</span><span style="color: rgb(102, 102, 0); font-size: 13.63636302947998px; line-height: 27.99715805053711px; white-space: pre;">></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);"></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">addArmatureFileInfo</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">(</span><span class="str" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 136, 0);">"Export/CsAnim0.png"</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">,</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);"> </span><span class="str" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 136, 0);">"Export/CsAnim0.plist"</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">,</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);"> </span><span class="str" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 136, 0);">"Export/CsAnim.ExportJson"</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">);</span></li><li class="L1" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);"><span class="typ" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; color: rgb(102, 0, 102);">ArmatureDataManager</span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">::</span><span class="pln" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">sharedArmatureDataManager</span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">()-</span><span style="font-size: 13.63636302947998px; line-height: 27.99715805053711px; white-space: pre;">></span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;"></span><span class="pln" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">addArmatureFileInfo</span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">(</span><span class="str" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; color: rgb(0, 136, 0);">"Export/CsAnim1.png"</span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="str" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; color: rgb(0, 136, 0);">"Export/CsAnim1.plist"</span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="str" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; color: rgb(0, 136, 0);">"Export/CsAnim.ExportJson"</span><span class="pun" style="font-family: inherit; font-style: inherit; line-height: 27.99715805053711px; white-space: pre; margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">);</span>
</span></li><li class="L2" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);"> </span></li><li class="L3" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="com" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(136, 0, 0);">// 这里直接使用 CsAnim ,而此信息保存在 CsAnim.ExportJson 中,与其创建的项目属性相对应  </span></li><li class="L4" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">cs</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">::</span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 0, 102);">Armature</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">*</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);"> armature </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">=</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);"> cs</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">::</span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 0, 102);">Armature</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">::</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">create</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">(</span><span class="str" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 136, 0);">"CsAnim"</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">);</span></li><li class="L5" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="com" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(136, 0, 0);">// 设置当前运行动画的索引,一个“工程”可以建立多个动画</span></li><li class="L6" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">armature</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">-</span><span style="color: rgb(102, 102, 0); font-size: 13.63636302947998px; line-height: 27.99715805053711px; white-space: pre;">></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);"></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">getAnimation</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">()-</span><span style="color: rgb(102, 102, 0); font-size: 13.63636302947998px; line-height: 27.99715805053711px; white-space: pre;">></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);"></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">playByIndex</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">(</span><span class="lit" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 102, 102);">0</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">);</span></li><li class="L7" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="com" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(136, 0, 0);">// 设置位置信息</span></li><li class="L8" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">armature</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">-></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">setPosition</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">(</span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 0, 102);">VisibleRect</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">::</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">center</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">());</span></li><li class="L9" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="com" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(136, 0, 0);">// 添加到容器,当前运行的场景之中</span></li><li class="L0" style="color: rgb(51, 51, 51); margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; text-align: left; line-height: 2em; list-style: decimal;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">this->addChild</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(0, 0, 0);">armature</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent; font-style: inherit; font-family: inherit; color: rgb(102, 102, 0);">);</span></li></ol>


5 骨骼动画的创建

前面我们使用了 CocoStudio 动画编辑器创建并在游戏中使用了序列帧动画,那么我们现在看看怎么使用其创建骨骼动画,相比序列帧动画,其导出的文件使用方法和序列帧相同,这里详细介绍下怎么使用动画编辑器创建骨骼动画。

骨骼动画创建步骤稍微复杂,请注意版本变化,操作可能不同

http://bbs.cocostudio.org/forum.php?mod=viewthread&tid=168&extra=page%3D1

  1. 首先创建项目,把准备好的资源图片导入 

  2. 我们需要得资源一个个拖动到“渲染视图”并摆放好位置关系,注意“对象视图”可以上下移动层次,以改变显示的位置关系(前后关系)Ctrl+鼠标滚轮可以放大或是缩小“渲染视图”,空格加拖动可以拖动渲染视图,方便编辑
  3. 位置摆好,我们就开始创建骨骼体系了,我们以身体作为基准创建
  4. 修改编辑模式,默认是动画模式,点击工具栏“动画模式”,然后会转变成“体型模式”,然后点击“停止创建骨骼”会转变为“创建骨骼模式”,然后就可以添加骨骼,我们在身体的部位用鼠标画出骨骼!可以连续画出多个。 

  5. 退出“创建骨骼模式”至“停止创建骨骼”模式,我们看到骨骼已经画出,现在要做的就是资源素材与骨骼的绑定,和骨骼的结构关系设定。
  6. 右击渲染场景的资源,选择“绑定到骨头”,然后选择骨骼(选择的骨头高亮显示),依次设定绑定所有 

  7. “如果绑定,可能会丢失图层帧信息,是否继续?”直接是即可。
  8. 右击骨骼“绑定到父亲”,依次根据身体部位设定好。

依照以上方法设定好资源图片与骨骼的对应关系,当然还有各骨骼之间的“父子”关系。 至此骨骼体系已经创建完成,下面则是基于此创建动画效果

  1. 首先切换到“动画模式”,不同的模式功用不同
  2. 选中当前帧的所有层,并且复制  

  3. 复制之后,在“如”第十五帧之处右击粘贴  

  4. 以上的复制粘贴的目的是为了使动画的首帧与尾帧相同,完成一个动画循环效果 

  5. 有了首尾帧,我们便可在中间帧编辑动画,选中“如”第六帧,然后拖动如图“手枪”骨骼 

  6. 点击播放就能看见动画效果了,我们可以在定位到其它帧,然后编辑骨骼的位置关系,最终创建出达到我们预期效果的骨骼动画

使用 CocoStudio 的动画编辑器来创建动画的简单步骤如上过程,这里只是简单快速的 “预览” 了一下其功能,但是更多的需要用户动手的实际操作~

    7.细心的同学会发现自己做出来的骨骼动画怪怪的,那是因为我们没有调整图片的锚点,图片的旋转等效果都是根据锚点的位置进行的!我们需要在资源管理区调整锚点即可。

  

转 http://blog.csdn.net/weizeteng_/article/details/17307539

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
About CocoStudio is a game development tool kit based on Cocos2d-x. It breaks down tasks in game development into different roles, it includes: UI editor for UI graphic artists, Animation editor for graphic artists, Number cruncher for game data designers, Scene editor for game designers CocoStudio forms a complete game development solution. The UI editor The UI was designed to serve its only purpose: create UI for games. Its simple and intuitive interface allows graphic artists to focus on their expertise, without worrying about other aspects such as programming. Currently the UI editor has 12 different UI elements ready to be used in games, new UI elements will be added with each and every release of CocoStudio, Other key features that the UI editor supports are: Texture packaging - Automatically packs individual texture files into a single large sprite, which further saves memory and improves game performance. Multi-resolution adaption - Automatically adapts to multiple resolution sizes with relative UI positioning. Templating - Reuse the same UI layout across different games, swap out texture resources to give it a new look. The Animation editor The Animation editor was designed to feel like Adobe Flash, which makes graphic artists feel right at home. The Animation editor brings skeletal animation to Cocos2d-x. What advantage does skeletal animation holds against the traditional frame animation? Lower memory consumption - An animation with the traditional frame based solution could use dozens of individual textures, but with skeletal animation, only 1 set of body parts is required to make infinite number of different animations. Smaller file size - due to less number of assets. Animation blending - you can combine animations together to easily make new animation, for example, you could blend attacking animation with walk animation to create "attacking while walking animation". Animation reuse - you can share skeletal animations with another character with the same skeleton setup. Smooth interpolation - traditional frame based animation is very choppy especially in slow motion. Skeletal animation interpolates between 2 sets of key frames, so animation is always played at the same frame rate as the game. However Skeletal animation cannot replace the traditional frame based animation, for example, it cannot make isometric character, it cannot make explosion, that is why we did not forget frame based animation, we even made it better and simpler. You only have to drag and drop frame sequences to the work space, and the animation editor will automatically creates the frame animation for you. Other highlight of Animation editor includes: WYSIWYG collision box editing - editing collision box in wysiwyg way has never being easier and accurate. Reference point - enables characters to wield swords, mount horses, and attaching other objects easily. Texture packing - Automatically packs individual texture files into a single large sprite, which further saves memory and improves game performance. The Data Cruncher The data Cruncher imports excel tables and converts the data into a format readable by cocos2d-x, which can also be used as a component for the Scene editor. The Scene editor The scene editor pieces all the assets made by the UI editor, Animation editor, and the Data Cruncher into a game scene, it can then simulate the game inside the editor. The scene editor also supports many assets made from third party editors such as particle designer, tiled etc. The scene editor relies on the CocosStudio Framework. CocoStudio Framework CocoStudio Framework is an open source higher level framework on top of Cocos2d-x, it employes entity and component system, it is used to read the data saved from the scene editor. The Scene editor saves data in a MVC like fashion, it includes all entities and events used in the current scene, and exports to corresponding code template for the programmers. A programmer can then write the code in Javascript to bring the game alive. CocoStudio的安装 1.CocoStudio的运行平台是Windows操作系统,推荐使用Windows7操作系统。 2.安装CocoStudio之前,确保电脑安装了.Net 4.0 Framework 3.安装目录尽量不要在C盘的Program Files文件夹下,可能会导致启动器无法启动编辑器。当然,通过“以管理员身份运行”的方式也可以打开软件 4.在Xp和Windows8的操作系统下,可能会出现的闪屏或无法运行的问题。这个问题会尽快修复

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值