class_scenetreetimer.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. .. 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. \ **Note:** The timer is processed after all of the nodes in the current frame, i.e. node's :ref:`Node._process<class_Node_private_method__process>` method would be called before the timer (or :ref:`Node._physics_process<class_Node_private_method__physics_process>` if ``process_in_physics`` in :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>` has been set to ``true``).
  31. .. rst-class:: classref-reftable-group
  32. Properties
  33. ----------
  34. .. table::
  35. :widths: auto
  36. +---------------------------+-----------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`time_left<class_SceneTreeTimer_property_time_left>` |
  38. +---------------------------+-----------------------------------------------------------+
  39. .. rst-class:: classref-section-separator
  40. ----
  41. .. rst-class:: classref-descriptions-group
  42. Signals
  43. -------
  44. .. _class_SceneTreeTimer_signal_timeout:
  45. .. rst-class:: classref-signal
  46. **timeout**\ (\ ) :ref:`🔗<class_SceneTreeTimer_signal_timeout>`
  47. Emitted when the timer reaches 0.
  48. .. rst-class:: classref-section-separator
  49. ----
  50. .. rst-class:: classref-descriptions-group
  51. Property Descriptions
  52. ---------------------
  53. .. _class_SceneTreeTimer_property_time_left:
  54. .. rst-class:: classref-property
  55. :ref:`float<class_float>` **time_left** :ref:`🔗<class_SceneTreeTimer_property_time_left>`
  56. .. rst-class:: classref-property-setget
  57. - |void| **set_time_left**\ (\ value\: :ref:`float<class_float>`\ )
  58. - :ref:`float<class_float>` **get_time_left**\ (\ )
  59. The time remaining (in seconds).
  60. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  61. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  62. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  63. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  64. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  65. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  66. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  67. .. |void| replace:: :abbr:`void (No return value.)`