Timer.xml 3.1 KB

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