Files
godot-docs/classes/class_scenetreetimer.rst
2021-10-06 11:19:07 +02:00

81 lines
2.6 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the SceneTreeTimer.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_SceneTreeTimer:
SceneTreeTimer
==============
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
One-shot timer.
Description
-----------
A one-shot timer managed by the scene tree, which emits :ref:`timeout<class_SceneTreeTimer_signal_timeout>` on completion. See also :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`.
As opposed to :ref:`Timer<class_Timer>`, it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example:
.. tabs::
.. code-tab:: gdscript
func some_function():
print("Timer started.")
yield(get_tree().create_timer(1.0), "timeout")
print("Timer ended.")
.. code-tab:: csharp
public async void SomeFunction()
{
GD.Print("Timer started.");
await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
GD.Print("Timer ended.");
}
Properties
----------
+---------------------------+-----------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`time_left<class_SceneTreeTimer_property_time_left>` |
+---------------------------+-----------------------------------------------------------+
Signals
-------
.. _class_SceneTreeTimer_signal_timeout:
- **timeout** **(** **)**
Emitted when the timer reaches 0.
Property Descriptions
---------------------
.. _class_SceneTreeTimer_property_time_left:
- :ref:`float<class_float>` **time_left**
+----------+----------------------+
| *Setter* | set_time_left(value) |
+----------+----------------------+
| *Getter* | get_time_left() |
+----------+----------------------+
The time remaining.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`