spineRunTime for cocos2dx v3 中删除SkeletonAnimation,发现下面写法会崩溃:
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) {
//cout<<trackIndex <<" end"<<endl;
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) {
//cout<<trackIndex <<" end"<<endl;
animationNode->runAction(CCSequence::create(CCDelayTime::create(0.01),CCRemoveSelf::create(),NULL));
});