您好 我给您粘下我这边的详细代码
//#######################以下代码 是创建动画对象和操作的部分#################
Armature * armature = Armature::create(“TestAnimation”);
armature->setTag(++i);
//获取衔接中的动画元素,并且添加动作事件监听
ArmatureAnimation animation = armature->getAnimation();
animation->setMovementEventCallFunc(this, SEL_MovementEventCallFunc(&HelloWorld::animationCallBack));
//animation->setFrameEventCallFunc(this, SEL_FrameEventCallFunc(&HelloWorld::animationCallBack));
auto test = animation->getAnimationData();
//添加到父节点
addChild(armature);
CCLog("%x", armature);
//播放动画中的myParticle 动作节点
animation->playByIndex(0, -1, 0);
//armature->setScale(1.5);
armature->setPosition(ccp(visibleSize.width0.25, visibleSize.height*0.25));
//#####################以下是我通过 setMovementEventCallFunc 监听的动画播放完毕
//在if (movementType == COMPLETE)中的注释掉的那些代码,我都尝试过了,都不能正常删除,删除后大概间隔个0.xx总之很短的时间会报一个错(错误在最下边)
void HelloWorld::animationCallBack(Armature *armature, MovementEventType movementType, const std::string& movementID){
CCLog(“run…~~~ %d”, movementType);
if (movementType == COMPLETE){
//armature->getAnimation()->setMovementEventCallFunc(NULL, NULL);
//CCLog("run....~~~");
//armature->getAnimation()->gotoAndPause(15);
//
//armature->stopAllActions();
//armature->unscheduleAllSelectors();
//armature->unscheduleUpdate();
//removeChild(armature);//这里移除后会报错
//armature->release();
//armature->autorelease();
}
}
报错信息截图在附件,我感觉好像是这个动画对象没有在全局的update回调中移除,我remove以后这个类因为是new出来的 里边做了 autorelease处理,所以自己释放掉了,然后 全局的update回调引用没有删除,所以引起错误了,我是新手不知道是不是这样,求助