Hi guys.
I have a problem regarding the lives in my game. Basically at the moment I have my game with my character which you move along the screen (well the background moves) and meteors fall from the sky through tweens. What I want to happen is when the character gets hit by a meteor he loses a life. Currently when he gets hit for every milisecond the meteor is touching him the ‘lives’ scorevalue decreases so it’s as if the number goes from 3 to -7, -7 to -12, as he gets hit. I get what it’s doing but I want it so for every time he gets hit he only loses one life, so it’ll only decrease by one. Here is my current code for when he gets hit:
var gameLives:Number = 3;
livesDisplay_txt.text="3";
function cometCollision(evt:Event):void{
if(characterBoy_mc.hitTestObject(comet_mc)){
livesDisplay_txt.text=String(gameLives);
gameLives--;
}
}
stage.addEventListener(Event.ENTER_FRAME, cometCollision);