class_scenetreetimer.rst 2.7 KB

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