hi, I’m trying to make a game, there’s lots of enemies and one player, here’s the problem:
when the player hits an enemy, I need to check which enemy it is. So I was thinking to use a loop that loop through all the enemy MC(enemy_0, enemy_1, enemy_2,enemy_3…):
var enemyNumber:Number = 50
for(var i:Number=0; i<=enemyNumber; i++){
if(this.hitTest(_root["enemy"+i])){
//code here......
}
}
but later I thought this isn’t very effective, so I decided to put this ON EACH ENEMY:
this.onEnterFrame=function(){
if(_root.playerClip.hitTest(this)){
//code here......
}
}
can you tell me which one is better?
thanks a lot