[COLOR=#000000][FONT=Arial]I am making a game where insects from above the screen move downwards to the bottom. The object is for the player to kill these insects with his/her mouse. When killed the insect should show a kill frame, where I have put in. The kill frame will stay there for 3 seconds and the object will be removed. This will also increase the player’s score.
[/FONT][/COLOR][COLOR=#000000][FONT=Arial]
This code is written inside the insect:
function kill(event:MouseEvent):void
{
this.dead = true;
}
[/FONT][/COLOR][COLOR=#000000][FONT=Arial]This code is written inside the background movieclip frame.
function moveEnemies():void
{
var tempEnemy:MovieClip;
tempEnemy = enemies*;
if (tempEnemy.dead)
{
tempEnemy.gotoAndStop(21);
var myTimer:Timer = new Timer(3000);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
myTimer.start();
}
}
}
function timerListener (e:TimerEvent):void
{
for (var i:int =enemies.length-1; i>=0; i--)
{
if (tempEnemy.dead)
{
score++;
roachLevel.score_txt.text = String(score);
removeEnemy(i);
}
}
}
function removeEnemy(id:int)
{
removeChild(enemies[id]);
enemies.splice(id,1); }
[/FONT][/COLOR]