class_scenetreetimer.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/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. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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>`.
  15. 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:
  16. .. tabs::
  17. .. code-tab:: gdscript
  18. func some_function():
  19. print("Timer started.")
  20. await get_tree().create_timer(1.0).timeout
  21. print("Timer ended.")
  22. .. code-tab:: csharp
  23. public async Task SomeFunction()
  24. {
  25. GD.Print("Timer started.");
  26. await ToSignal(GetTree().CreateTimer(1.0f), SceneTreeTimer.SignalName.Timeout);
  27. GD.Print("Timer ended.");
  28. }
  29. 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>`.
  30. .. rst-class:: classref-reftable-group
  31. Properties
  32. ----------
  33. .. table::
  34. :widths: auto
  35. +---------------------------+-----------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`time_left<class_SceneTreeTimer_property_time_left>` |
  37. +---------------------------+-----------------------------------------------------------+
  38. .. rst-class:: classref-section-separator
  39. ----
  40. .. rst-class:: classref-descriptions-group
  41. Signals
  42. -------
  43. .. _class_SceneTreeTimer_signal_timeout:
  44. .. rst-class:: classref-signal
  45. **timeout** **(** **)**
  46. Emitted when the timer reaches 0.
  47. .. rst-class:: classref-section-separator
  48. ----
  49. .. rst-class:: classref-descriptions-group
  50. Property Descriptions
  51. ---------------------
  52. .. _class_SceneTreeTimer_property_time_left:
  53. .. rst-class:: classref-property
  54. :ref:`float<class_float>` **time_left**
  55. .. rst-class:: classref-property-setget
  56. - void **set_time_left** **(** :ref:`float<class_float>` value **)**
  57. - :ref:`float<class_float>` **get_time_left** **(** **)**
  58. The time remaining (in seconds).
  59. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  60. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  61. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  62. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  63. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  64. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`