Create a timer object set time passed in
timeLeft number optionalHow much time left before the timer is elapsed in seconds (undefined = unset)
useRealTime boolean optional, default falseShould the timer keep running even when the game is paused? (useful for UI)
let a = new Timer; // creates a timer that is not set
a.set(3); // sets the timer to 3 seconds
let b = new Timer(1); // creates a timer with 1 second left
b.unset(); // unset the timer
Runs on real time, so it keeps going while the game is paused, see setUseRealTime
Returns true if set and has not elapsed
Returns true if set and elapsed
Get how long since elapsed, returns 0 if not set (returns negative if currently active)
Get the current global time this timer is based on
Get percentage elapsed based on time it was set to, returns 0 if not set.
Zero-duration timers report 1 (already elapsed).
Get the time this timer was set to, returns 0 if not set
Set the timer with seconds passed in
timeLeft number optional, default 0How much time left before the timer is elapsed in seconds
Set if the timer should keep running even when the game is paused
useRealTime boolean optional, default true
Returns this timer expressed as a string
Get how long since elapsed, returns 0 if not set (returns negative if currently active)