Cocos2d-X 学习笔记 13 cocos2dx骨骼动画



不全是和原版一样,我做了一定的修改来更方便的生成数据。
blog: rainynote.com
使用说明:1.安装 SkeletonSWFPanel.zxp





2.如果安装不成功,可以手动拷贝文件 1.3\SkeletonSWFPanel\SkeletonSWFPanel\bin-debug 里的 SkeletonSWFPanel.swf和

SkeletonSWFPanel 文件夹到

C:\Users\youyou\AppData\Local\Adobe\Flash CS6\zh_CN\Configuration\WindowSWF\SkeletonSWFPanel这是WIN7下的做法,其他系统不大清楚。



3.打开Flash cs6 -> 窗口 ->其他面板 -> SkeletonSWFPanel



4. import-> 选择一个 你想要的 导入方式导入 动画.






tween time : 两个动作切换 需要花的时间,比如 由 stand 切换到 run中间的 tween 时间

animation time :这个动作持续的时间

stage frameRate : 指的是 游戏 的帧率,因为可能不同的朋友 需要不同帧率的游戏,在这里设定了帧率再去调animation time后,你在游戏中 以同样的帧率来运行游戏,就能看到和在工具上显示的 动画效果 是一样的。(这个设定 是为了方便你调射动画速度,因为 Flash中默认是 24 帧 )

bone animation delay : 这是一个很有用的设定,操作时 选中
中的一个元素后 再调这个值,效果,举例说 如果只有 做了两帧动画,如果只播放这两帧动画,则会出现 所有 的 bone 的 动作的速率是一样的 ,

图中所示上面的马 的腿 的动作 是一样的,下面的马腿 设定了 延时 动作,这样出现一前一后跑动的效果,比较真实,不会死板。



5. 1.0的 骨骼从属需要手动 设置 很是繁琐,现在只要 在 bone框内就可以拖动从属关系。


6.export :这里提供了三种 保存方式, pngswf 单个文件 ,单个文件主要是方便我们自己可以选择打包方式,png 方式 会把xml信息也压缩进 png里。


程序里面需要做的就是:
// step 1: add your skeleton xml file
//CCConnectionData::sharedConnectionData()->addData("knight.xml");
CCConnectionData::sharedConnectionData()->addData("zombie.xml");

// step2: add plist and png to cache
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("zombie.plist","zombie.png");

// step 3: create a CCSpriteBatchNode
//CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create("knight.png");
CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create( "zombie.png" );

// step 4: create a armature just need armature name,plist,picture,and a CCSpriteBatchNode
// armature = CCArmature::cr eate("Knight_f/Knight","Knight_f/Knight","knight.plist","knight.png",batchNode);
armature = CCArmature::create("Zombie_f/Zombie","Zombie_f/Zombie",batchNode);

armature->getDisplay()->setPosition(ccp(size.width/2,size.height/2));
armature->getDisplay()->setScale( 1 );

// step 5: play the animation
armature->getAnimation()->playTo("stand");

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...