reaven said:its says [cant say this in english so sry about that..
kan klasse of inteface niet laden.
and heres the chekenemyhitt
Code:
function checkEnemyHitt(_enemy:MovieClip):Void
{
for(var i = 0; i < enemyArray.length; i++)
{
var tempEnemy:MovieClip = enemyArray[i];
if(deathwall.hitTest(tempEnemy))
{
destroyEnemy(tempEnemy);
}
if(player_mc.hitTest(tempEnemy))
{
_root.hud1.playerhp =_root.hud1.playerhp - 1;
}
}
}
What crisis meant, is that you have a function named:
Code:function checkEnemyHitt(_enemy:MovieClip):Void
You're passing the variable _enemy as a function parameter, while you're never use that variable anywhere. It's maybe best to do it like this:
Code:function checkEnemyHitt(enemyArray:Array, obstacles:Array):Void
now you can double loop this. you can check for each enemy if it did hit any obstacle like the deathwall.
in untested some sort of semi-pseudo code it would look something like this:
Code:// check enemy hittest
// enemyArray is full of enemy objects, the movieclip is stored in .clip
// like enemyArray.push({clip: movieClipReferenceVar, health: 5})
function checkEnemyHit(enemyArray:Array, obstacles:Array):Void {
for (var i:int = 0; i < enemyArray.length; i++) {
for (var j:int = 0; j < obstacles.length; j++) {
if (enemyArray[i].clip.hitTest(obstacles[j])) {
enemyArray[i].health--;
// if enemy is dead
if (enemyArray[i].health <= 0) {
destroyEnemy(enemyArray[i]); // refer to destroyEnemy function
}
// remove obstacle
removeObstacle(obstacles[j]); // refer to removeObstacle function
}
}
}
}
