zoukankan      html  css  js  c++  java
  • spineRunTime for cocos2dx v3 中动画播完删除animation

    spineRunTime for cocos2dx v3 中删除animation,发现下面写法会崩溃:  

        spine::SkeletonAnimation* animationNode = spine::SkeletonAnimation::createWithFile("explosion/explosion.json", "explosion/explosion.atlas", 1);

            animationNode->setAnimation(0, "animation", false);

            animationNode->setPosition(ccp(x,y));

        animationNode->setEndListener( [animationNode] (int trackIndex) {

         //spTrackEntry* entry = spAnimationState_getCurrent(animationNode->getState(), trackIndex);

                //const char* t_animationName = (entry && entry->animation) ? entry->animation->name : 0;

                //string animationName=t_animationName==0?"":t_animationName;

                //CCLOG("%d end: %s", trackIndex, animationName.c_str());

                animationNode->removeFromParentAndCleanup(true);

            });

    于是只好通过加一个延迟来避免崩溃,下面是可用的写法:

       spine::SkeletonAnimation* animationNode = spine::SkeletonAnimation::createWithFile("explosion/explosion.json", "explosion/explosion.atlas", 1);

            animationNode->setAnimation(0, "animation", false);

            animationNode->setPosition(ccp(x,y));

        animationNode->setEndListener( [animationNode] (int trackIndex) {

         //spTrackEntry* entry = spAnimationState_getCurrent(animationNode->getState(), trackIndex);

                //const char* t_animationName = (entry && entry->animation) ? entry->animation->name : 0;

                //string animationName=t_animationName==0?"":t_animationName;

                //CCLOG("%d end: %s", trackIndex, animationName.c_str());

                animationNode->runAction(CCSequence::create(CCDelayTime::create(0.01),CCRemoveSelf::create(),NULL));

            });

    或者用completeListener,仍然需要加延迟:

      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==0?"":t_animationName;

                //CCLOG("%d complete: %s %d", trackIndex, animationName.c_str(),loopCount);

                animationNode->runAction(CCSequence::create(CCDelayTime::create(0.01),CCRemoveSelf::create(),NULL));

                

            });

  • 相关阅读:
    AlphaMobileControls
    .NET Compact Framework下注册表导出工具的开发
    windows moblie 5.0在托管程序中实现短信接收和拦截
    自定义MessageBox
    Windows Mobile 背景灯控制
    windows Mobile 启动Mobile Office
    windows mobile 5.0 进程管理、窗体管理、重启和关闭操作系统
    让Windows Mobile模拟器通过你的PC上网
    Windows Mobile获取存储卡容量及使用情况
    透明背景
  • 原文地址:https://www.cnblogs.com/wantnon/p/4483112.html
Copyright © 2011-2022 走看看