|
5 | 5 | </brief_description> |
6 | 6 | <description> |
7 | 7 | The [Timer] node is a countdown timer and is the simplest way to handle time-based logic in the engine. When a timer reaches the end of its [member wait_time], it will emit the [signal timeout] signal. |
8 | | - After a timer enters the tree, it can be manually started with [method start]. A timer node is also started automatically if [member autostart] is [code]true[/code]. |
| 8 | + After a timer enters the scene tree, it can be manually started with [method start]. A timer node is also started automatically if [member autostart] is [code]true[/code]. |
9 | 9 | Without requiring much code, a timer node can be added and configured in the editor. The [signal timeout] signal it emits can also be connected through the Node dock in the editor: |
10 | 10 | [codeblock] |
11 | 11 | func _on_timer_timeout(): |
12 | 12 | print("Time to attack!") |
13 | 13 | [/codeblock] |
14 | 14 | [b]Note:[/b] To create a one-shot timer without instantiating a node, use [method SceneTree.create_timer]. |
15 | | - [b]Note:[/b] Timers are affected by [member Engine.time_scale]. The higher the time scale, the sooner timers will end. How often a timer processes may depend on the framerate or [member Engine.physics_ticks_per_second]. |
| 15 | + [b]Note:[/b] Timers are affected by [member Engine.time_scale] unless [member ignore_time_scale] is [code]true[/code]. The higher the time scale, the sooner timers will end. How often a timer processes may depend on the framerate or [member Engine.physics_ticks_per_second]. |
16 | 16 | </description> |
17 | 17 | <tutorials> |
18 | 18 | <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/2712</link> |
|
28 | 28 | <return type="void" /> |
29 | 29 | <param index="0" name="time_sec" type="float" default="-1" /> |
30 | 30 | <description> |
31 | | - Starts the timer, or resets the timer if it was 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]. |
| 31 | + Starts the timer, or resets the timer if it was started already. Fails if the timer is not inside the scene tree. If [param time_sec] is greater than [code]0[/code], this value is used for the [member wait_time]. |
32 | 32 | [b]Note:[/b] This method does not resume a paused timer. See [member paused]. |
33 | 33 | </description> |
34 | 34 | </method> |
35 | 35 | <method name="stop"> |
36 | 36 | <return type="void" /> |
37 | 37 | <description> |
38 | | - Stops the timer. |
| 38 | + Stops the timer. See also [member paused]. Unlike [method start], this can safely be called if the timer is not inside the scene tree. |
| 39 | + [b]Note:[/b] Calling [method stop] does not emit the [signal timeout] signal, as the timer is not considered to have timed out. If this is desired, use [code]$Timer.timeout.emit()[/code] after calling [method stop] to manually emit the signal. |
39 | 40 | </description> |
40 | 41 | </method> |
41 | 42 | </methods> |
|
52 | 53 | If [code]true[/code], the timer will stop after reaching the end. Otherwise, as by default, the timer will automatically restart. |
53 | 54 | </member> |
54 | 55 | <member name="paused" type="bool" setter="set_paused" getter="is_paused"> |
55 | | - 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. |
| 56 | + 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. See also [method stop]. |
56 | 57 | </member> |
57 | 58 | <member name="process_callback" type="int" setter="set_timer_process_callback" getter="get_timer_process_callback" enum="Timer.TimerProcessCallback" default="1"> |
58 | 59 | Specifies when the timer is updated during the main loop. |
|
0 commit comments