原文是在 :http://www.mengwuji.net/forum.php?mod=viewthread&tid=1431
更新3.1.1 都添加了;确保正确。。=
注意::3.0+版本中,尽量不要使用cocosstudio的动画了,因为它的内存删除真的是有一个bug;至今没有修复。另外,泄露泄露很严重。bug方法:注释中已经给出了,这个bug在2.2.3中没有;3.0+版本包括最新3.1.1版本中依旧存在。所以不建议使用cocosstudio……
bug呈现:
void fun1{
CCArmatureDataManager ::getInstance()->addArmatureFileInfo( mppngName,mplistName,mpJsonName);
armature = CCArmature ::create(pJsonName );
armature->getAnimation()->setSpeedScale(1.5); //播放速度,1是正常,0.2放慢。
armature->getAnimation()->play( “Animation1” );//播放FireWithoutBullet动画
//设置帧事件;播放完动画,被攻击的人的位置。
armature->getAnimation()->setMovementEventCallFunc(this,SEL_MovementEventCallFunc(&GameScene::animationCallBack));
this->addChild(armature);
armature->setVisible(true);
Point curPos=pNodeBAttack->getPosition();
armature->setPosition(curPos);
}
void GameScene::animationCallBack(Armature *armature, MovementEventType movementType, const std::string& movementID)
{
//说明;直接删除会崩溃;
if (movementType == COMPLETE)是引擎错误·!!!;在回调外删除没事。
{
//armature->getAnimation()->setMovementEventCallFunc(NULL, NULL);
//armature->getAnimation()->gotoAndPause(15);
//armature->stopAllActions();
//armature->unscheduleAllSelectors();
//armature->unscheduleUpdate();
// removeChild(armature);//这里移除后会报错
//armature->release();
//armature->autorelease();
// armature->removeFromParentAndCleanup(true);
} // end if (movementType == COMPLETE)
}