I want my enemies to take away from my health after a certain time its on the stage.
So right now I have an array of enemies that pop at random.
How do you do this? This is what I have so far:
Actionscript Code:
var tmr1:Timer=new Timer(2800);
var tmr2:Timer=new Timer(5000);
Actionscript Code:
}
public function targets(e:MouseEvent):void {
iTarget=-1;
for (i = 0; i<arTargets.length; i++) {
if (arTargets[i].hitTestPoint(mouseX,mouseY,true)) {
iTarget=i;
}
}
if (iTarget!=-1) {
nEnemyH-=1;
}
if (nEnemyH==0) {
removeChild(arTargets[iTarget]);
nEnemyH=5;
}
}
function addTargets(e:TimerEvent) {
dX=Math.random()*875;
dY=Math.random()*400;
t=new Enemy2();
t.x=dX;
t.y=dY;
arTargets.push(t);
addChild(t);
tmr2.start();
if (t.visible==true){
tmr2.start();
}
if (tmr2.currentCount%2==Uint){
line.x=dX
line.y=dY
addChild(line)
}
if (tmr1.currentCount==30) {
tmr1.stop();
}
}
As you can see tmr1 adds the enemies.
tmr2 is me trying to figure out the losing HP.