;

PDA

Click to See Complete Forum and Search --> : PLEASE needs urgent help on timer on game


gillygillybee
04-18-2009, 06:17 PM
hi, i am having a problem with my flash animation game timer and nothing seems to work
i want it so that when the time reaches 60 seconds and the score is over 200 it will go to the frame gameWon if its below it will go to gameLost.

i also am struggling to make the timer show up on the animation game.

i would be so grateful if you could help.. heren is my code...

stop();
var score:Number=0;
addEventListener(Event.ENTER_FRAME,testHit);
function testHit(e:Event){
if (kissBoy.hitTestObject(kissGirl)){
trace("Hit");
score+=5;
scoreDisplay.text="score:"+score
}
}
function reached60Seconds(e:TimerEvent):void {
if (score>200) {
gotoAndStop("gameWon");
} else {
gotoAndStop("gameLost");
}
}
var myTimer:Timer=new Timer(60000,1);
myTimer.addEventListener(TimerEvent.TIMER,reached6 0Seconds);
myTimer.start();
function reached60seconds(event:TimerEvent):void{
trace("TimerTriggered");
}
function runalltime(evt:Event):void{
if (kissBoy.hitTestPoint(kissGirl.x,kissGirl.y,true)) {
kissGirl.x=Math.random()*400;
kissGirl.y=Math.random()*300;
}
}

function keydetect(evt:KeyboardEvent):void{
if(evt.keyCode==Keyboard.RIGHT){
kissBoy.x+=10;
}

if(evt.keyCode==Keyboard.LEFT){
kissBoy.x-=10;
}

if(evt.keyCode==Keyboard.UP){
kissBoy.y-=10;
}

if(evt.keyCode==Keyboard.DOWN){
kissBoy.y+=10;
}
}


stage.addEventListener(Event.ENTER_FRAME,runalltim e);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyd etect);

cancerinform
04-18-2009, 08:55 PM
You have the function reached60seconds twice in your script. The latest function will be executed. delete the latest one.