A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: PLEASE needs urgent help on timer on game

Threaded View

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    1

    PLEASE needs urgent help on timer on game

    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...
    PHP 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); 
    Last edited by sstalder; 04-18-2009 at 06:27 PM. Reason: Please use the php / code tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center