class_timer.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Timer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Timer:
  6. Timer
  7. =====
  8. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A countdown timer.
  13. Properties
  14. ----------
  15. +------------------------------------------------------+--------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`autostart<class_Timer_property_autostart>` |
  17. +------------------------------------------------------+--------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`one_shot<class_Timer_property_one_shot>` |
  19. +------------------------------------------------------+--------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`paused<class_Timer_property_paused>` |
  21. +------------------------------------------------------+--------------------------------------------------------+
  22. | :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` | :ref:`process_mode<class_Timer_property_process_mode>` |
  23. +------------------------------------------------------+--------------------------------------------------------+
  24. | :ref:`float<class_float>` | :ref:`time_left<class_Timer_property_time_left>` |
  25. +------------------------------------------------------+--------------------------------------------------------+
  26. | :ref:`float<class_float>` | :ref:`wait_time<class_Timer_property_wait_time>` |
  27. +------------------------------------------------------+--------------------------------------------------------+
  28. Methods
  29. -------
  30. +-------------------------+------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_stopped<class_Timer_method_is_stopped>` **(** **)** const |
  32. +-------------------------+------------------------------------------------------------------------------------------+
  33. | void | :ref:`start<class_Timer_method_start>` **(** :ref:`float<class_float>` time_sec=-1 **)** |
  34. +-------------------------+------------------------------------------------------------------------------------------+
  35. | void | :ref:`stop<class_Timer_method_stop>` **(** **)** |
  36. +-------------------------+------------------------------------------------------------------------------------------+
  37. Signals
  38. -------
  39. .. _class_Timer_signal_timeout:
  40. - **timeout** **(** **)**
  41. Emitted when the timer reaches 0.
  42. Enumerations
  43. ------------
  44. .. _enum_Timer_TimerProcessMode:
  45. .. _class_Timer_constant_TIMER_PROCESS_PHYSICS:
  46. .. _class_Timer_constant_TIMER_PROCESS_IDLE:
  47. enum **TimerProcessMode**:
  48. - **TIMER_PROCESS_PHYSICS** = **0** --- Update the timer during the physics step at each frame (fixed framerate processing).
  49. - **TIMER_PROCESS_IDLE** = **1** --- Update the timer during the idle time at each frame.
  50. Description
  51. -----------
  52. Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one shot" mode.
  53. Property Descriptions
  54. ---------------------
  55. .. _class_Timer_property_autostart:
  56. - :ref:`bool<class_bool>` **autostart**
  57. +----------+----------------------+
  58. | *Setter* | set_autostart(value) |
  59. +----------+----------------------+
  60. | *Getter* | has_autostart() |
  61. +----------+----------------------+
  62. If ``true``, the timer will automatically start when entering the scene tree. Default value: ``false``.
  63. ----
  64. .. _class_Timer_property_one_shot:
  65. - :ref:`bool<class_bool>` **one_shot**
  66. +----------+---------------------+
  67. | *Setter* | set_one_shot(value) |
  68. +----------+---------------------+
  69. | *Getter* | is_one_shot() |
  70. +----------+---------------------+
  71. If ``true``, the timer will stop when reaching 0. If ``false``, it will restart. Default value: ``false``.
  72. ----
  73. .. _class_Timer_property_paused:
  74. - :ref:`bool<class_bool>` **paused**
  75. +----------+-------------------+
  76. | *Setter* | set_paused(value) |
  77. +----------+-------------------+
  78. | *Getter* | is_paused() |
  79. +----------+-------------------+
  80. If ``true``, the timer is paused and will not process until it is unpaused again, even if :ref:`start<class_Timer_method_start>` is called.
  81. ----
  82. .. _class_Timer_property_process_mode:
  83. - :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` **process_mode**
  84. +----------+-------------------------------+
  85. | *Setter* | set_timer_process_mode(value) |
  86. +----------+-------------------------------+
  87. | *Getter* | get_timer_process_mode() |
  88. +----------+-------------------------------+
  89. Processing mode. See :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>`.
  90. ----
  91. .. _class_Timer_property_time_left:
  92. - :ref:`float<class_float>` **time_left**
  93. +----------+-----------------+
  94. | *Getter* | get_time_left() |
  95. +----------+-----------------+
  96. The timer's remaining time in seconds. Returns 0 if the timer is inactive.
  97. Note: You cannot set this value. To change the timer's remaining time, use :ref:`wait_time<class_Timer_property_wait_time>`.
  98. ----
  99. .. _class_Timer_property_wait_time:
  100. - :ref:`float<class_float>` **wait_time**
  101. +----------+----------------------+
  102. | *Setter* | set_wait_time(value) |
  103. +----------+----------------------+
  104. | *Getter* | get_wait_time() |
  105. +----------+----------------------+
  106. Wait time in seconds.
  107. Method Descriptions
  108. -------------------
  109. .. _class_Timer_method_is_stopped:
  110. - :ref:`bool<class_bool>` **is_stopped** **(** **)** const
  111. Returns ``true`` if the timer is stopped.
  112. ----
  113. .. _class_Timer_method_start:
  114. - void **start** **(** :ref:`float<class_float>` time_sec=-1 **)**
  115. Starts the timer. Sets ``wait_time`` to ``time_sec`` if ``time_sec > 0``. This also resets the remaining time to ``wait_time``.
  116. Note: this method will not resume a paused timer. See :ref:`paused<class_Timer_property_paused>`.
  117. ----
  118. .. _class_Timer_method_stop:
  119. - void **stop** **(** **)**
  120. Stops the timer.