class_scenetreetimer.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/SceneTreeTimer.xml.
  6. .. _class_SceneTreeTimer:
  7. SceneTreeTimer
  8. ==============
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. One-shot timer.
  11. Description
  12. -----------
  13. 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>`.
  14. 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:
  15. .. tabs::
  16. .. code-tab:: gdscript
  17. func some_function():
  18. print("Timer started.")
  19. await get_tree().create_timer(1.0).timeout
  20. print("Timer ended.")
  21. .. code-tab:: csharp
  22. public async void SomeFunction()
  23. {
  24. GD.Print("Timer started.");
  25. await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
  26. GD.Print("Timer ended.");
  27. }
  28. The timer will be dereferenced after its time elapses. To preserve the timer, you can keep a reference to it. See :ref:`RefCounted<class_RefCounted>`.
  29. Properties
  30. ----------
  31. +---------------------------+-----------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`time_left<class_SceneTreeTimer_property_time_left>` |
  33. +---------------------------+-----------------------------------------------------------+
  34. Signals
  35. -------
  36. .. _class_SceneTreeTimer_signal_timeout:
  37. - **timeout** **(** **)**
  38. Emitted when the timer reaches 0.
  39. Property Descriptions
  40. ---------------------
  41. .. _class_SceneTreeTimer_property_time_left:
  42. - :ref:`float<class_float>` **time_left**
  43. +----------+----------------------+
  44. | *Setter* | set_time_left(value) |
  45. +----------+----------------------+
  46. | *Getter* | get_time_left() |
  47. +----------+----------------------+
  48. The time remaining (in seconds).
  49. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  50. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  51. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  52. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  53. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  54. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`