Code:enemies.push({clip: enemymovieclip, hp: 5});
with "enemymovieclip" i meant the variable name in which you store the movieclips you attach to the root.
so:
Code:var tempEnemy:MovieClip = _root.attachMovie(enemyLibraryClip, // ... etc
// and then
enemies.push({clip: tempEnemy, hp: 5});
but this is really confusing me. i see you use two arrays now: enemies and enemyArray. I think you should make it:
Code:enemyArray.push({clip: tempEnemy, hp: 5});
and forget the enemies array.
Also, since tempEnemy is a movieclip object in which you already store variables, you can also store HP like this:
Code:
if(enemyBehavior == "typeA")
{
tempEnemy.hp = 10; // store hp here
tempEnemy.health = 10;
tempEnemy.speed = 1;
tempEnemy.turnRate = .05;
tempEnemy.agroRange = 200;
tempEnemy.mode = "follow"
}
In this case you don't need to store objects in the array anymore and now you can simply do:
Code:enemyArray.push(tempEnemy);
To get the hp for an enemy, you can simply loop the array:
Code:
for(var i = 0; i < enemyArray.length; i++) {
trace("hp for enemy #"+i+" is: "+enemyArray[i].hp);
}
is this what you want?
because you're explanation is sometimes so foggy that my eyes hurt lol
