cocos2dx3.2 spine动画

前端之家收集整理的这篇文章主要介绍了cocos2dx3.2 spine动画前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

首先提供spine的最新运行库,当然这不是官方的,里面封装了ffd,是我自己修改过并添加了ffd代码,采用newSkeletonAnimation区别原先的skeletonAnimation具体点击:spine FFD runtime

其中要注意的几个地方:
1. 1.8版本以上的atlas做了修改 在第二行添加了size 所以只要删除size这一行即可,
2. 动作制作的时候如果层级有发生改变或者切换了skin,slot,请K帧一下,修改的部分:draworder和bone,一般首尾都K一下就行了。
3.至于.skel的binary文件,是spine本身就提供的二进制文件性能必然高于json,本人目前正在修改完善spine runtime的binary(因为官方也不提供,完成起来慢了点,以后或许会放出)。
4.newskeletonanimation在create时候最后一个参数scale别忘了。
说一下runtime中常用的一些方法
skeletonNode = NEWSkeletonAnimation::createWithFile("spineboy.json","spineboy.atlas",0.6f);//创建动作,最后的参数为scale.


?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
skeletonNode->startListener = [ this ] ( int trackIndex) { //设置动作开始检测的监听器
spTrackEntry* entry = spAnimationState_getCurrent(skeletonNode->state,trackIndex); //获得当前动作的状态信息
const char * animationName = (entry && entry->animation) ? entry->animation->name : 0;
log ( "%d start: %s" ,trackIndex,animationName);
};
skeletonNode->endListener = [] ( //同理,结束动作监听
"%d end" };
skeletonNode->completeListener = [] ( trackIndex, loopCount) { //同理,完成动作监听
"%d complete: %d" };
skeletonNode->eventListener = [] ( //同理,事件监听,在spine中编辑好event导出
"%d event: %s,%d,%f,%s" };
skeletonNode->setMix( "walk" "jump" //协调动作
"run" skeletonNode->setAnimation(0, true ); //设置动作,可用多个set进行动作混合
spTrackEntry* jumpEntry = skeletonNode->addAnimation(0,153)!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:auto!important; background:none!important">false //添加动作,在上个动作直接玩之后,之后为循环参数和delay
skeletonNode->addAnimation(0,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:auto!important; background:none!important">);
skeletonNode->setStartListener(jumpEntry,[] ( trackIndex) {
"jumped!" );
});
skeletonNode->timeScale = 0.3f; //动作间隔
skeletonNode->debugBones = ; //debug模式
skeletonNode->update(0); //更新动作
spBone* root=skeletonNode->findBone( "root" //找到name为root的骨骼,同理 通过 findslot 可以找到名字为name的slot



@H_360_301@

1
NEWSkeletonAnimation* skeletonNode;
21
skeletonNode = NEWSkeletonAnimation::createWithFile( "Maid.json" "Maid.atlas"
trackIndex) {
* animationName = (entry && entry->animation) ? entry->animation->name : 0;
};
skeletonNode->endListener = [=] ( trackIndex) {
m_isSkeletonSiwtch = ;
loopCount) {
};
};
skeletonNode->setPosition(100,100);
->addChild(skeletonNode);
//skeletonNode->setAnimation(0,"Event",false);

源地址:http://my.oschina.net/ffs/blog/316972
原文链接:https://www.f2er.com/cocos2dx/339971.html

猜你在找的Cocos2d-x相关文章