直接上代码
void BattleEffectLayer::showEffect()
{
Armature* tempEffect = Armature::create("effect1");
this->addChild(tempEffect);
tempEffect->setPosition(320,inter->getValue());
tempEffect->getAnimation()->playWithIndex(0);
tempEffect->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(BattleEffectLayer::effectOver,this,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
}
void BattleEffectLayer::effectOver(Armature *armature, MovementEventType movementType, const std::string& movementID)
{
if (movementType == LOOP_COMPLETE)
{
// armature->getAnimation()->stop();
// armature->stopAllActions();
this->removeChild(armature);
//this->removeChild(armature);
//armature = nullptr;
// this->removeChild(armature);
//this->removeChild(armature);
//armature->setVisible(false);
// armature->getAnimation()->stop();
}
}
只要从显示表中删除armature 就会报内存 出错的问题 个人感觉 armature 删除了 但是armature中的动画控制 还在运行 之前有哥们说用removeFromParentAndCleanup()这个函数就行了。亲测还是不行 高手有碰到的吗 有什么方法 给支个招3.0rc0 3.0rc1都测试了 还是不行


