Timer.xml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Timer" inherits="Node" version="3.2">
  3. <brief_description>
  4. A countdown timer.
  5. </brief_description>
  6. <description>
  7. Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one-shot" mode.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="is_stopped" qualifiers="const">
  13. <return type="bool">
  14. </return>
  15. <description>
  16. Returns [code]true[/code] if the timer is stopped.
  17. </description>
  18. </method>
  19. <method name="start">
  20. <return type="void">
  21. </return>
  22. <argument index="0" name="time_sec" type="float" default="-1">
  23. </argument>
  24. <description>
  25. Starts the timer. Sets [code]wait_time[/code] to [code]time_sec[/code] if [code]time_sec &gt; 0[/code]. This also resets the remaining time to [code]wait_time[/code].
  26. [b]Note:[/b] this method will not resume a paused timer. See [member paused].
  27. </description>
  28. </method>
  29. <method name="stop">
  30. <return type="void">
  31. </return>
  32. <description>
  33. Stops the timer.
  34. </description>
  35. </method>
  36. </methods>
  37. <members>
  38. <member name="autostart" type="bool" setter="set_autostart" getter="has_autostart" default="false">
  39. If [code]true[/code], the timer will automatically start when entering the scene tree.
  40. [b]Note:[/b] This property is automatically set to [code]false[/code] after the timer enters the scene tree and starts.
  41. </member>
  42. <member name="one_shot" type="bool" setter="set_one_shot" getter="is_one_shot" default="false">
  43. If [code]true[/code], the timer will stop when reaching 0. If [code]false[/code], it will restart.
  44. </member>
  45. <member name="paused" type="bool" setter="set_paused" getter="is_paused">
  46. If [code]true[/code], the timer is paused and will not process until it is unpaused again, even if [method start] is called.
  47. </member>
  48. <member name="process_mode" type="int" setter="set_timer_process_mode" getter="get_timer_process_mode" enum="Timer.TimerProcessMode" default="1">
  49. Processing mode. See [enum TimerProcessMode].
  50. </member>
  51. <member name="time_left" type="float" setter="" getter="get_time_left">
  52. The timer's remaining time in seconds. Returns 0 if the timer is inactive.
  53. [b]Note:[/b] You cannot set this value. To change the timer's remaining time, use [method start].
  54. </member>
  55. <member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time" default="1.0">
  56. Wait time in seconds.
  57. </member>
  58. </members>
  59. <signals>
  60. <signal name="timeout">
  61. <description>
  62. Emitted when the timer reaches 0.
  63. </description>
  64. </signal>
  65. </signals>
  66. <constants>
  67. <constant name="TIMER_PROCESS_PHYSICS" value="0" enum="TimerProcessMode">
  68. Update the timer during the physics step at each frame (fixed framerate processing).
  69. </constant>
  70. <constant name="TIMER_PROCESS_IDLE" value="1" enum="TimerProcessMode">
  71. Update the timer during the idle time at each frame.
  72. </constant>
  73. </constants>
  74. </class>