其中要注意的几个地方:
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中常用的一些方法:
1 skeletonNode = NEWSkeletonAnimation::createWithFile("spineboy.json", "spineboy.atlas", 0.6f);//创建动作,最后的参数为scale. 2 3 4 5 skeletonNode->startListener = [this] (int trackIndex) {//设置动作开始检测的监听器 6 spTrackEntry* entry = spAnimationState_getCurrent(skeletonNode->state, trackIndex);//获得当前动作的状态信息 7 const char* animationName = (entry && entry->animation) ? entry->animation->name : 0; 8 log("%d start: %s", trackIndex, animationName); 9 }; 10 skeletonNode->endListener = [] (int trackIndex) {//同理,结束动作监听 11 log("%d end", trackIndex); 12 }; 13 skeletonNode->completeListener = [] (int trackIndex, int loopCount) {//同理,完成动作监听 14 log("%d complete: %d", trackIndex, loopCount); 15 }; 16 skeletonNode->eventListener = [] (int trackIndex, spEvent* event) {//同理,事件监听,在spine中编辑好event导出 17 log("%d event: %s, %d, %f, %s", trackIndex, event->data->name, event->intValue, event->floatValue, event->stringValue); 18 }; 19 20 skeletonNode->setMix("walk", "jump", 0.2f);//协调动作 21 skeletonNode->setMix("jump", "run", 0.2f); 22 skeletonNode->setAnimation(0, "walk", true);//设置动作,可用多个set进行动作混合 23 spTrackEntry* jumpEntry = skeletonNode->addAnimation(0, "jump", false, 3);//添加动作,在上个动作直接玩之后,之后为循环参数和delay 24 skeletonNode->addAnimation(0, "run", true); 25 26 skeletonNode->setStartListener(jumpEntry, [] (int trackIndex) { 27 log("jumped!"); 28 }); 29 30 skeletonNode->timeScale = 0.3f;//动作间隔 31 skeletonNode->debugBones = true;//debug模式 32 skeletonNode->update(0);//更新动作 33 spBone* root=skeletonNode->findBone("root");//找到name为root的骨骼,同理 通过 findslot 可以找到名字为name的slot
1 skeletonNode = NEWSkeletonAnimation::createWithFile("Maid.json", "Maid.atlas", 0.6f); 2 3 skeletonNode->startListener = [this] (int trackIndex) { 4 spTrackEntry* entry = spAnimationState_getCurrent(skeletonNode->state, trackIndex); 5 const char* animationName = (entry && entry->animation) ? entry->animation->name : 0; 6 log("%d start: %s", trackIndex, animationName); 7 }; 8 skeletonNode->endListener = [=] (int trackIndex) { 9 log("%d end", trackIndex); 10 m_isSkeletonSiwtch = false; 11 }; 12 skeletonNode->completeListener = [] (int trackIndex, int loopCount) { 13 log("%d complete: %d", trackIndex, loopCount); 14 }; 15 skeletonNode->eventListener = [] (int trackIndex, spEvent* event) { 16 log("%d event: %s, %d, %f, %s", trackIndex, event->data->name, event->intValue, event->floatValue, event->stringValue); 17 }; 18 19 skeletonNode->setPosition(100, 100); 20 this->addChild(skeletonNode); 21 //skeletonNode->setAnimation(0, "Event", false);
//this->runAction(Sequence::createWithTwoActions(FadeOut::create(1.5), CallFunc::create([this](){ // m_pToufaTemp->removeFromParentAndCleanup(true); // })));