class_timer.rst 5.7 KB

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