class_timer.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Timer:
  4. Timer
  5. =====
  6. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. A simple Timer node.
  11. Member Functions
  12. ----------------
  13. +----------------------------+------------------------------------------------------------------------------------------------------------+
  14. | :ref:`float<class_float>` | :ref:`get_time_left<class_Timer_get_time_left>` **(** **)** const |
  15. +----------------------------+------------------------------------------------------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`get_timer_process_mode<class_Timer_get_timer_process_mode>` **(** **)** const |
  17. +----------------------------+------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`get_wait_time<class_Timer_get_wait_time>` **(** **)** const |
  19. +----------------------------+------------------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`has_autostart<class_Timer_has_autostart>` **(** **)** const |
  21. +----------------------------+------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`is_active<class_Timer_is_active>` **(** **)** const |
  23. +----------------------------+------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`is_one_shot<class_Timer_is_one_shot>` **(** **)** const |
  25. +----------------------------+------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_active<class_Timer_set_active>` **(** :ref:`bool<class_bool>` active **)** |
  27. +----------------------------+------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`set_autostart<class_Timer_set_autostart>` **(** :ref:`bool<class_bool>` enable **)** |
  29. +----------------------------+------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_one_shot<class_Timer_set_one_shot>` **(** :ref:`bool<class_bool>` enable **)** |
  31. +----------------------------+------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_timer_process_mode<class_Timer_set_timer_process_mode>` **(** :ref:`int<class_int>` mode **)** |
  33. +----------------------------+------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_wait_time<class_Timer_set_wait_time>` **(** :ref:`float<class_float>` time_sec **)** |
  35. +----------------------------+------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`start<class_Timer_start>` **(** **)** |
  37. +----------------------------+------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`stop<class_Timer_stop>` **(** **)** |
  39. +----------------------------+------------------------------------------------------------------------------------------------------------+
  40. Signals
  41. -------
  42. - **timeout** **(** **)**
  43. Emitted when the time runs out.
  44. Numeric Constants
  45. -----------------
  46. - **TIMER_PROCESS_FIXED** = **0** --- Update the timer at fixed intervals (framerate processing).
  47. - **TIMER_PROCESS_IDLE** = **1** --- Update the timer during the idle time at each frame.
  48. Description
  49. -----------
  50. Timer node. This is a simple node that will emit a timeout callback when the timer runs out. It can optionally be set to loop.
  51. Member Function Description
  52. ---------------------------
  53. .. _class_Timer_get_time_left:
  54. - :ref:`float<class_float>` **get_time_left** **(** **)** const
  55. Return the time left for timeout in seconds if the timer is active, 0 otherwise.
  56. .. _class_Timer_get_timer_process_mode:
  57. - :ref:`int<class_int>` **get_timer_process_mode** **(** **)** const
  58. Return the timer's processing mode.
  59. .. _class_Timer_get_wait_time:
  60. - :ref:`float<class_float>` **get_wait_time** **(** **)** const
  61. Return the wait time in seconds.
  62. .. _class_Timer_has_autostart:
  63. - :ref:`bool<class_bool>` **has_autostart** **(** **)** const
  64. Return true if set to automatically start when entering the scene.
  65. .. _class_Timer_is_active:
  66. - :ref:`bool<class_bool>` **is_active** **(** **)** const
  67. Return if the timer is active or not.
  68. .. _class_Timer_is_one_shot:
  69. - :ref:`bool<class_bool>` **is_one_shot** **(** **)** const
  70. Return true if configured as one-shot.
  71. .. _class_Timer_set_active:
  72. - void **set_active** **(** :ref:`bool<class_bool>` active **)**
  73. Set whether the timer is active or not. An inactive timer will be paused until it is activated again.
  74. .. _class_Timer_set_autostart:
  75. - void **set_autostart** **(** :ref:`bool<class_bool>` enable **)**
  76. Set to automatically start when entering the scene.
  77. .. _class_Timer_set_one_shot:
  78. - void **set_one_shot** **(** :ref:`bool<class_bool>` enable **)**
  79. Set as one-shot. If enabled, the timer will stop after timeout, otherwise it will automatically restart.
  80. .. _class_Timer_set_timer_process_mode:
  81. - void **set_timer_process_mode** **(** :ref:`int<class_int>` mode **)**
  82. Set the timer's processing mode (fixed or idle, use TIMER_PROCESS\_\* constants as argument).
  83. .. _class_Timer_set_wait_time:
  84. - void **set_wait_time** **(** :ref:`float<class_float>` time_sec **)**
  85. Set wait time in seconds. When the time is over, it will emit the timeout signal.
  86. .. _class_Timer_start:
  87. - void **start** **(** **)**
  88. Start the timer.
  89. .. _class_Timer_stop:
  90. - void **stop** **(** **)**
  91. Stop (cancel) the timer.