2
0

Timer.xml 3.1 KB

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