Timer

Inherits: Node < Object

Category: Core

Brief Description

A countdown timer.

Member Functions

float get_time_left ( ) const
bool is_paused ( ) const
bool is_stopped ( ) const
void set_paused ( bool paused )
void start ( )
void stop ( )

Signals

  • timeout ( )

Emitted when the Timer reaches 0.

Member Variables

  • bool autostart - If true, Timer will automatically start when entering the scene tree. Default value: false.
  • bool one_shot - If true, Timer will stop when reaching 0. If false, it will restart. Default value: false.
  • int process_mode - Processing mode. Uses TIMER_PROCESS_* constants as value.
  • float wait_time - Wait time in seconds.

Numeric Constants

  • TIMER_PROCESS_PHYSICS = 0 — Update the Timer during the physics step at each frame (fixed framerate processing).
  • TIMER_PROCESS_IDLE = 1 — Update the Timer during the idle time at each frame.

Description

Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or “one shot” mode.

Member Function Description

  • float get_time_left ( ) const

Return the time left for timeout in seconds if the timer is active, 0 otherwise.

  • bool is_paused ( ) const

Return if the timer is paused or not.

  • bool is_stopped ( ) const
  • void set_paused ( bool paused )

Set whether the timer is paused or not. A paused timer will be inactive until it is unpaused again.

  • void start ( )

Start the Timer.

  • void stop ( )

Stop (cancel) the Timer.