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_active ( ) const
bool is_one_shot ( ) const
void set_active ( bool active )
void set_autostart ( bool enable )
void set_one_shot ( bool enable )
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_active ( ) const

Return if the timer is active or not.

bool is_one_shot ( ) const

Return true if configured as one-shot.

void set_active ( bool active )

Set whether the timer is active or not. An inactive timer will be paused until it is activated again.

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_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.

© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/2.1/classes/class_timer.html