RockHopper Games
04-03-2011, 02:55 AM
I have multiple objects on screen that are all part of an array. I want them all to be removed after a hitTest. Everything's working ok except that only one object is being removed.
for(var i:int = 0; i < enemyList.length; i++){
if (enemyList[i].hitTestObject(man)) {
var enemy = enemyList.indexOf(i)
man.removeEventListener(Event.ENTER_FRAME, checkHitTest);
this.removeChild(enemyList.splice(i, 1)[0]);
}
}
I played around with it a bit, but ultimately, I need some help. Does anyone know what I'm doing wrong here? The this.removeChild is the problem, but I'm just not sure why it's not working.
for(var i:int = 0; i < enemyList.length; i++){
if (enemyList[i].hitTestObject(man)) {
var enemy = enemyList.indexOf(i)
man.removeEventListener(Event.ENTER_FRAME, checkHitTest);
this.removeChild(enemyList.splice(i, 1)[0]);
}
}
I played around with it a bit, but ultimately, I need some help. Does anyone know what I'm doing wrong here? The this.removeChild is the problem, but I'm just not sure why it's not working.