class_scenetreetimer.rst 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. Properties
  28. ----------
  29. +---------------------------+-----------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`time_left<class_SceneTreeTimer_property_time_left>` |
  31. +---------------------------+-----------------------------------------------------------+
  32. Signals
  33. -------
  34. .. _class_SceneTreeTimer_signal_timeout:
  35. - **timeout** **(** **)**
  36. Emitted when the timer reaches 0.
  37. Property Descriptions
  38. ---------------------
  39. .. _class_SceneTreeTimer_property_time_left:
  40. - :ref:`float<class_float>` **time_left**
  41. +----------+----------------------+
  42. | *Setter* | set_time_left(value) |
  43. +----------+----------------------+
  44. | *Getter* | get_time_left() |
  45. +----------+----------------------+
  46. The time remaining.
  47. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  48. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  49. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  50. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  51. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  52. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`