嘿,我在移除我的敌人方块时遇到问题。目前,如果我击中每个人,一切都很好,但是当我避开一个时,我会收到一条错误消息
ArgumentError:错误 #2025:提供的 DisplayObject 必须是调用者的子对象。在 flash.display::DisplayObjectContainer/removeChild() 在 EnergyJump/onTick() 在 flash.utils::Timer/flash.utils:Timer::_timerDispatch() 在 flash.utils::Timer/flash.utils:Timer::打钩()
这是我的代码:
public function onTick( timerEvent:TimerEvent ):void
{
//if ranrom number is than than i
if ( Math.random() < i )
{
//place block on stage at location X=550, Y=330
var randomX:Number = Math.random() * 550;
var newBlock:Blocks = new Blocks( 550, 335 );
army.push( newBlock );
addChild( newBlock );
//increase speed of spawn
i = i + 0.0001;
}
//move blocks in correct direction
for each ( var block:Blocks in army )
{
block.move();
//if block is hit then remove health and remove child object
if ( avatar.hitTestObject( block ) )
{
hp.checkHP(20);
army.splice(army.indexOf(block), 1);
removeChild( block );
}
}
}
谁能帮助我,说实话,我真的不知道切片是什么或如何使用它...