当我击中我的对象命中作品时,我想将我的对象从视图容器中删除,也从数组中删除,但我不想将它从舞台上删除。因为数组中的索引为空。好的,但是你如何删除它呢?
谢谢
private function enemySpawnen():void
{
var enemyShip:SpaceShip = new SpaceShip();
Enemy[0] = enemyShip;
Enemy[1] = enemyShip;
}
private function renderEnemy(e:Event):void
{
if(Enemy[0] != null){
viewContainer.addChild(Enemy[0]);
Enemy[0].scaleX = 0.5;
Enemy[0].scaleY = 0.5;
Enemy[0].x = 600;
Enemy[0].y = 400;
}
else{
viewContainer.removeChild(Enemy[0]);==> problem
}
}
if(spaceBar){
var kogel:Kogel = new Kogel();
viewContainer.addChild(kogel);
kogel.scaleX = 0.08;
kogel.scaleY = 0.08;
kogel.x = heli.x + (heli.width/2) -225;
kogel.y = heli.y + (heli.height/2) + 30;
kogel.addEventListener(Event.ENTER_FRAME, shoot);
function shoot(e:Event):void
{
kogel.x +=10;
try{
if(kogel.hitTestObject(Enemy[0])){
Enemy.splice(0,1);
}
}
catch(e:Error){
}
}