Skip to content
0.2.0-dev Download ZIP
42 lines ·1.7 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="SceneTreeTimer" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 One-shot timer.
5 </brief_description>
6 <description>
7 A one-shot timer managed by the scene tree, which emits [signal timeout] on completion. See also [method SceneTree.create_timer].
8 As opposed to [Timer], it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example:
9 [codeblocks]
10 [gdscript]
11 func some_function():
12 print("Timer started.")
13 await get_tree().create_timer(1.0).timeout
14 print("Timer ended.")
15 [/gdscript]
16 [csharp]
17 public async Task SomeFunction()
18 {
19 GD.Print("Timer started.");
20 await ToSignal(GetTree().CreateTimer(1.0f), SceneTreeTimer.SignalName.Timeout);
21 GD.Print("Timer ended.");
22 }
23 [/csharp]
24 [/codeblocks]
25 The timer will be dereferenced after its time elapses. To preserve the timer, you can keep a reference to it. See [RefCounted].
26 [b]Note:[/b] The timer is processed after all of the nodes in the current frame, i.e. node's [method Node._process] method would be called before the timer (or [method Node._physics_process] if [code]process_in_physics[/code] in [method SceneTree.create_timer] has been set to [code]true[/code]).
27 </description>
28 <tutorials>
29 </tutorials>
30 <members>
31 <member name="time_left" type="float" setter="set_time_left" getter="get_time_left">
32 The time remaining (in seconds).
33 </member>
34 </members>
35 <signals>
36 <signal name="timeout">
37 <description>
38 Emitted when the timer reaches 0.
39 </description>
40 </signal>
41 </signals>
42</class>