Timer

A timer for tracking countdown durations with pause/resume functionality.

Constructor

  • Timer(duration: SupportsFloat) Timer

A timer for tracking countdown durations with pause/resume functionality.

Properties


NameDescriptionType
donebool: True if the timer has finished counting down, False otherwise.bool
elapsed_timefloat: The time elapsed since the timer was started, in seconds.float
progressfloat: The completion progress of the timer as a value between 0.0 and 1.0.float
time_remainingfloat: The remaining time in seconds before the timer completes.float

Methods


Pause

pause() None

Pause the timer countdown.

The timer will stop counting down but retain its current state. Use resume() to continue the countdown from where it was paused. Has no effect if the timer is not started or already paused.

Reset

reset() None

Reset the timer to its initial state.

Stops the timer and resets it back to its initial, unstarted state. The timer can be started again with start() after being reset.

Resume

resume() None

Resume a paused timer countdown.

Continues the countdown from where it was paused. Has no effect if the timer is not started or not currently paused.

Start

start() None

Start or restart the timer countdown.

This begins the countdown from the full duration. If the timer was previously started, this will reset it back to the beginning.