首页 > 其他 > 详细

spineRuntTime for cocos2dx v3,attack播完后回到idle

时间:2015-05-08 21:53:47      阅读:773      评论:0      收藏:0      [点我收藏+]

spineRuntTime for cocos2dx v3,attack播完后回到idle。

_animationNode = spine::SkeletonAnimation::createWithFile("animations/skeleton.json", "animations/skeleton.atlas", 1.0);
_animationNode->setAnimation(0, "idle", true);
_animationNode->setPosition(ccp(x,y));
addChild(_animationNode);

_animationNode->setCompleteListener( [_animationNode] (int trackIndex, int loopCount) {
  spTrackEntry* entry = spAnimationState_getCurrent(_animationNode->getState(), trackIndex);
  const char* t_animationName = (entry && entry->animation) ? entry->animation->name : 0;
  string animationName=t_animationName;
  //CCLOG("%d complete: %s %d", trackIndex, animationName.c_str(),loopCount);
  if(animationName=="attack"){
    _animationNode->setAnimation(0, "idle", true);
  }
});

 

需要特别注意的是:必须用CompleteListener,而不能用EndListener(会崩溃),参考:https://github.com/EsotericSoftware/spine-runtimes/issues/150

 

spineRuntTime for cocos2dx v3,attack播完后回到idle

原文:http://www.cnblogs.com/wantnon/p/4488722.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!