1 Reply Latest reply on Apr 3, 2007 4:35 PM by Lukewig

    Timer

    npo rule
      Hi

      I am creating a game and I want to put in a timer so that when say 1 minute is up the user is taken to another frame.

      Is there any other way of doing this without using the countdown timer?

      Thanks
        • 1. Re: Timer
          Lukewig Level 1
          Hi,

          There are two ways:

          1. Record the start time and then every game cycle (eg every exitframe), see how long has passed.

          2. Create a timeout object to make a callback after the desired time period.

          Example of the first approach (this is in a frame script)

          property EndTime
          on beginSprite (me)
          EndTime = the milliseconds + (60 * 1000)
          end

          on exitframe (me)
          if the milliseconds > EndTime then go to "GameOver"
          else go to the frame
          end


          An example of the seconds approachj

          on beginSprite (me)
          timr = timeout().new("GameClock, 60000, #EndGame, me)
          end

          on EndGame (me)
          go to "GameOver"
          end

          -- Luke