最近发现,美术导出的spine动画, 在真机上播放的时候,偶尔出现漠明其妙的错乱问题,比如角色的头歪了、一个动作后有些地方对不齐了,等等类似问题。尝试了比对动作文件,跟到代码里等方式,也没找到原因。
刚花了点时间,系统查了一下,原来是runTime 代码太老了。一段时间没关注,github上已经早更新了
//注册事件 l_skeleton->setAnimationListener(this, animationStateEvent_selector(SpineEffectMgr::onAnimationStateEvent));
//回调方法
#pragma mark AnimationListener void SpineEffectMgr::onAnimationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount){ if(type == ANIMATION_END || type == ANIMATION_COMPLETE){ node->removeFromParentAndCleanup(true); map<string, spine::CCSkeletonAnimation*>::iterator iter; for (iter = m_spineEffectMap.begin(); iter != m_spineEffectMap.end(); iter++) { if((*iter).second == node){ m_spineEffectMap.erase(iter); break; } } } }
之前,都是用每帧监听的方式去看,动作有没有结束,这次更新后。在处理一些事件上就很方便了。