2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 08:08:05 +00:00
<class name= "Timer" inherits= "Node" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
A countdown timer.
</brief_description>
<description >
2019-06-21 23:04:47 +00:00
Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one-shot" mode.
2023-04-23 08:21:18 +00:00
[b]Note:[/b] Timers are affected by [member Engine.time_scale], a higher scale means quicker timeouts, and vice versa.
2021-03-18 11:04:28 +00:00
[b]Note:[/b] To create a one-shot timer without instantiating a node, use [method SceneTree.create_timer].
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2020-10-01 08:34:47 +00:00
<link title= "2D Dodge The Creeps Demo" > https://godotengine.org/asset-library/asset/515</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
<method name= "is_stopped" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-20 17:49:05 +00:00
Returns [code]true[/code] if the timer is stopped or has not started.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "start" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "time_sec" type= "float" default= "-1" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-20 17:49:05 +00:00
Starts the timer, if it was not started already. Fails if the timer is not inside the tree. If [param time_sec] is greater than [code]0[/code], this value is used for the [member wait_time].
[b]Note:[/b] This method does not resume a paused timer. See [member paused].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "stop" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2018-09-16 17:52:21 +00:00
Stops the timer.
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2019-06-29 10:38:01 +00:00
<member name= "autostart" type= "bool" setter= "set_autostart" getter= "has_autostart" default= "false" >
2024-01-20 17:49:05 +00:00
If [code]true[/code], the timer will start immediately when it enters the scene tree.
[b]Note:[/b] After the timer enters the tree, this property is automatically set to [code]false[/code].
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "one_shot" type= "bool" setter= "set_one_shot" getter= "is_one_shot" default= "false" >
2024-01-20 17:49:05 +00:00
If [code]true[/code], the timer will stop after reaching the end. Otherwise, as by default, the timer will automatically restart.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 19:22:15 +00:00
<member name= "paused" type= "bool" setter= "set_paused" getter= "is_paused" >
2024-01-20 17:49:05 +00:00
If [code]true[/code], the timer is paused. A paused timer does not process until this property is set back to [code]false[/code], even when [method start] is called.
2018-01-11 22:38:35 +00:00
</member>
2021-02-19 12:35:31 +00:00
<member name= "process_callback" type= "int" setter= "set_timer_process_callback" getter= "get_timer_process_callback" enum= "Timer.TimerProcessCallback" default= "1" >
2024-01-20 17:49:05 +00:00
Specifies when the timer is updated during the main loop (see [enum TimerProcessCallback]).
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 19:22:15 +00:00
<member name= "time_left" type= "float" setter= "" getter= "get_time_left" >
2024-01-20 17:49:05 +00:00
The timer's remaining time in seconds. This is always [code]0[/code] if the timer is stopped.
[b]Note:[/b] This property is read-only and cannot be modified. It is based on [member wait_time].
2018-01-11 22:38:35 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "wait_time" type= "float" setter= "set_wait_time" getter= "get_wait_time" default= "1.0" >
2024-01-20 17:49:05 +00:00
The time required for the timer to end, in seconds. This property can also be set every time [method start] is called.
[b]Note:[/b] Timers can only process once per physics or process frame (depending on the [member process_callback]). An unstable framerate may cause the timer to end inconsistently, which is especially noticeable if the wait time is lower than roughly [code]0.05[/code] seconds. For very short timers, it is recommended to write your own code instead of using a [Timer] node. Timers are also affected by [member Engine.time_scale].
2017-09-12 20:42:36 +00:00
</member>
</members>
<signals >
<signal name= "timeout" >
<description >
2024-01-20 17:49:05 +00:00
Emitted when the timer reaches the end.
2017-09-12 20:42:36 +00:00
</description>
</signal>
</signals>
<constants >
2021-02-19 12:35:31 +00:00
<constant name= "TIMER_PROCESS_PHYSICS" value= "0" enum= "TimerProcessCallback" >
2024-01-20 17:49:05 +00:00
Update the timer every physics process frame (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]).
2017-09-12 20:42:36 +00:00
</constant>
2021-02-19 12:35:31 +00:00
<constant name= "TIMER_PROCESS_IDLE" value= "1" enum= "TimerProcessCallback" >
2024-01-20 17:49:05 +00:00
Update the timer every process (rendered) frame (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).
2017-09-12 20:42:36 +00:00
</constant>
</constants>
</class>