So here im checking for when a bullet hits an enemy ship in my game. Im trying to check the type of enemy in the array by object name to do specific things for that enemy, code is below.
for (var i = bullets.length - 1; i >= 0; i--) {
for (var j = enemies.length - 1; j >= 0; j--) {
if (_bullets[i].hitTestObject(enemies[j])) {
if (enemies[j] == EnemyYellow) {
trace("do something");
}
stage.removeChild(enemies[j]);
stage.removeChild(bullets[i]);
bullets.splice(i, 1);
enemies.splice(j, 1);
return;
}
}
}
This is something like I thought would work, but I would appreciate if anyone could help me out as im not sure how to do it.
if (enemies[j] == EnemyYellow) {
trace("do something");
}