Timer

Inherits: Node < Object

Category: Core

Brief Description

A simple Timer node.

Member Functions

float get_time_left ( ) const
int get_timer_process_mode ( ) const
float get_wait_time ( ) const
bool has_autostart ( ) const
bool is_one_shot ( ) const
bool is_paused ( ) const
bool is_stopped ( ) const
void set_autostart ( bool enable )
void set_one_shot ( bool enable )
void set_paused ( bool paused )
void set_timer_process_mode ( int mode )
void set_wait_time ( float time_sec )
void start ( )
void stop ( )

Signals

  • timeout ( )

Emitted when the time runs out.

Numeric Constants

  • TIMER_PROCESS_FIXED = 0 — Update the timer at fixed intervals (framerate processing).
  • TIMER_PROCESS_IDLE = 1 — Update the timer during the idle time at each frame.

Description

Timer node. This is a simple node that will emit a timeout callback when the timer runs out. It can optionally be set to loop.

Member Function Description

  • float get_time_left ( ) const

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

  • int get_timer_process_mode ( ) const

Return the timer’s processing mode.

  • float get_wait_time ( ) const

Return the wait time in seconds.

  • bool has_autostart ( ) const

Return true if set to automatically start when entering the scene.

  • bool is_one_shot ( ) const

Return true if configured as one-shot.

  • bool is_paused ( ) const

Return if the timer is paused or not.

  • bool is_stopped ( ) const
  • void set_autostart ( bool enable )

Set to automatically start when entering the scene.

  • void set_one_shot ( bool enable )

Set as one-shot. If enabled, the timer will stop after timeout, otherwise it will automatically restart.

  • 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 set_timer_process_mode ( int mode )

Set the timer’s processing mode (fixed or idle, use TIMER_PROCESS_* constants as argument).

  • void set_wait_time ( float time_sec )

Set wait time in seconds. When the time is over, it will emit the timeout signal.

  • void start ( )

Start the timer.

  • void stop ( )

Stop (cancel) the timer.