AGS: How Do I Make A Hidden Timer in AGS?

Started by Will, Mon 22/10/2018 14:37:25

Previous topic - Next topic

Will

Hello Guys,

Could you tell me how do I make a Hidden Countdown Timer to A Game in AGS? I would like to know. Thank you! :)
will :)

Matti

I'm not sure what you mean by hidden timer, but if you look up SetTimer in the manual I think you will find what you need.

Lewis

#2
Yeah, all timers are "hidden" unless you specifically script something to happen while the timer's running.

Assuming you just want to set a timer and have it count down to a game event, then

Code: ags
SetTimer(1, 80);


will set Timer No. 1 to 80 game loops, i.e. 2 seconds. You want to set this at the point in the script where you want the timer to start counting down.

Then, in RepEx, you control what happens when the timer reaches 0. This is so that the game is checking every loop to see if there's any time left.

Code: ags
if (IsTimerExpired(1)) //This continually checks whether or not Timer No. 1 has expired and returns the below if it has.
  {
    //Whatever you want to happen
  }
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

Will

Thanks but...

How do I know if I set by Let's just say 7 Seconds... What should be it's int timeout integer of it?
will :)

Khris

#4
Use this:
Code: ags
  SetTimer(1, GetGameSpeed() * 7);


That way the timer will expire after 7 seconds regardless of the frames per second setting (which is 40 by default, so you pass 280 or 40 * 7).

SMF spam blocked by CleanTalk