virtualx-engine-docs/_sources/classes/class_timer.rst.txt
2024-10-23 09:41:33 -07:00

279 lines
9.2 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Timer.xml.
.. _class_Timer:
Timer
=====
**Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
A countdown timer.
.. rst-class:: classref-introduction-group
Description
-----------
Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one-shot" mode.
\ **Note:** Timers are affected by :ref:`Engine.time_scale<class_Engine_property_time_scale>`, a higher scale means quicker timeouts, and vice versa.
\ **Note:** To create a one-shot timer without instantiating a node, use :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`.
.. rst-class:: classref-introduction-group
Tutorials
---------
- `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+------------------------------------------------------+--------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`autostart<class_Timer_property_autostart>` | ``false`` |
+------------------------------------------------------+--------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`one_shot<class_Timer_property_one_shot>` | ``false`` |
+------------------------------------------------------+--------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`paused<class_Timer_property_paused>` | |
+------------------------------------------------------+--------------------------------------------------------+-----------+
| :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` | :ref:`process_mode<class_Timer_property_process_mode>` | ``1`` |
+------------------------------------------------------+--------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`time_left<class_Timer_property_time_left>` | |
+------------------------------------------------------+--------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`wait_time<class_Timer_property_wait_time>` | ``1.0`` |
+------------------------------------------------------+--------------------------------------------------------+-----------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-------------------------+------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_stopped<class_Timer_method_is_stopped>` **(** **)** |const| |
+-------------------------+------------------------------------------------------------------------------------------+
| void | :ref:`start<class_Timer_method_start>` **(** :ref:`float<class_float>` time_sec=-1 **)** |
+-------------------------+------------------------------------------------------------------------------------------+
| void | :ref:`stop<class_Timer_method_stop>` **(** **)** |
+-------------------------+------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Signals
-------
.. _class_Timer_signal_timeout:
.. rst-class:: classref-signal
**timeout** **(** **)**
Emitted when the timer reaches 0.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumerations
------------
.. _enum_Timer_TimerProcessMode:
.. rst-class:: classref-enumeration
enum **TimerProcessMode**:
.. _class_Timer_constant_TIMER_PROCESS_PHYSICS:
.. rst-class:: classref-enumeration-constant
:ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` **TIMER_PROCESS_PHYSICS** = ``0``
Update the timer during the physics step at each frame (fixed framerate processing).
.. _class_Timer_constant_TIMER_PROCESS_IDLE:
.. rst-class:: classref-enumeration-constant
:ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` **TIMER_PROCESS_IDLE** = ``1``
Update the timer during the idle time at each frame.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_Timer_property_autostart:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **autostart** = ``false``
.. rst-class:: classref-property-setget
- void **set_autostart** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **has_autostart** **(** **)**
If ``true``, the timer will automatically start when entering the scene tree.
\ **Note:** This property is automatically set to ``false`` after the timer enters the scene tree and starts.
.. rst-class:: classref-item-separator
----
.. _class_Timer_property_one_shot:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **one_shot** = ``false``
.. rst-class:: classref-property-setget
- void **set_one_shot** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_one_shot** **(** **)**
If ``true``, the timer will stop when reaching 0. If ``false``, it will restart.
.. rst-class:: classref-item-separator
----
.. _class_Timer_property_paused:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **paused**
.. rst-class:: classref-property-setget
- void **set_paused** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_paused** **(** **)**
If ``true``, the timer is paused and will not process until it is unpaused again, even if :ref:`start<class_Timer_method_start>` is called.
.. rst-class:: classref-item-separator
----
.. _class_Timer_property_process_mode:
.. rst-class:: classref-property
:ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` **process_mode** = ``1``
.. rst-class:: classref-property-setget
- void **set_timer_process_mode** **(** :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` value **)**
- :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>` **get_timer_process_mode** **(** **)**
Processing mode. See :ref:`TimerProcessMode<enum_Timer_TimerProcessMode>`.
.. rst-class:: classref-item-separator
----
.. _class_Timer_property_time_left:
.. rst-class:: classref-property
:ref:`float<class_float>` **time_left**
.. rst-class:: classref-property-setget
- :ref:`float<class_float>` **get_time_left** **(** **)**
The timer's remaining time in seconds. Returns 0 if the timer is inactive.
\ **Note:** You cannot set this value. To change the timer's remaining time, use :ref:`start<class_Timer_method_start>`.
.. rst-class:: classref-item-separator
----
.. _class_Timer_property_wait_time:
.. rst-class:: classref-property
:ref:`float<class_float>` **wait_time** = ``1.0``
.. rst-class:: classref-property-setget
- void **set_wait_time** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_wait_time** **(** **)**
The wait time in seconds.
\ **Note:** Timers can only emit once per rendered frame at most (or once per physics frame if :ref:`process_mode<class_Timer_property_process_mode>` is :ref:`TIMER_PROCESS_PHYSICS<class_Timer_constant_TIMER_PROCESS_PHYSICS>`). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node. Timers are affected by :ref:`Engine.time_scale<class_Engine_property_time_scale>`, a higher scale means quicker timeouts, and vice versa.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_Timer_method_is_stopped:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_stopped** **(** **)** |const|
Returns ``true`` if the timer is stopped.
.. rst-class:: classref-item-separator
----
.. _class_Timer_method_start:
.. rst-class:: classref-method
void **start** **(** :ref:`float<class_float>` time_sec=-1 **)**
Starts the timer. Sets ``wait_time`` to ``time_sec`` if ``time_sec > 0``. This also resets the remaining time to ``wait_time``.
\ **Note:** This method will not resume a paused timer. See :ref:`paused<class_Timer_property_paused>`.
.. rst-class:: classref-item-separator
----
.. _class_Timer_method_stop:
.. rst-class:: classref-method
void **stop** **(** **)**
Stops the timer.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`