.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_Tween: Tween ===== **Inherits:** :ref:`Node` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Node useful for animations with unknown start and end points. Member Functions ---------------- +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`follow_method` **(** :ref:`Object` object, :ref:`String` method, :ref:`Variant` initial_val, :ref:`Object` target, :ref:`String` target_method, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`follow_property` **(** :ref:`Object` object, :ref:`String` property, :ref:`Variant` initial_val, :ref:`Object` target, :ref:`String` target_property, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_runtime` **(** **)** const | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_speed_scale` **(** **)** const | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_tween_process_mode` **(** **)** const | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`interpolate_callback` **(** :ref:`Object` object, :ref:`float` duration, :ref:`String` callback, :ref:`Variant` arg1=null, :ref:`Variant` arg2=null, :ref:`Variant` arg3=null, :ref:`Variant` arg4=null, :ref:`Variant` arg5=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`interpolate_deferred_callback` **(** :ref:`Object` object, :ref:`float` duration, :ref:`String` callback, :ref:`Variant` arg1=null, :ref:`Variant` arg2=null, :ref:`Variant` arg3=null, :ref:`Variant` arg4=null, :ref:`Variant` arg5=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`interpolate_method` **(** :ref:`Object` object, :ref:`String` method, :ref:`Variant` initial_val, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`interpolate_property` **(** :ref:`Object` object, :ref:`String` property, :ref:`Variant` initial_val, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_active` **(** **)** const | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_repeat` **(** **)** const | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`remove` **(** :ref:`Object` object, :ref:`String` key=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`remove_all` **(** **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`reset` **(** :ref:`Object` object, :ref:`String` key=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`reset_all` **(** **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`resume` **(** :ref:`Object` object, :ref:`String` key=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`resume_all` **(** **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`seek` **(** :ref:`float` time **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_active` **(** :ref:`bool` active **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_repeat` **(** :ref:`bool` repeat **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_speed_scale` **(** :ref:`float` speed **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_tween_process_mode` **(** :ref:`int` mode **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`start` **(** **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`stop` **(** :ref:`Object` object, :ref:`String` key=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`stop_all` **(** **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`targeting_method` **(** :ref:`Object` object, :ref:`String` method, :ref:`Object` initial, :ref:`String` initial_method, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`targeting_property` **(** :ref:`Object` object, :ref:`String` property, :ref:`Object` initial, :ref:`String` initial_val, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`tell` **(** **)** const | +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Signals ------- - **tween_complete** **(** :ref:`Object` object, :ref:`String` key **)** This signal is emitted when a tween ends. - **tween_start** **(** :ref:`Object` object, :ref:`String` key **)** This signal is emitted when a tween starts. - **tween_step** **(** :ref:`Object` object, :ref:`String` key, :ref:`float` elapsed, :ref:`Object` value **)** This signal is emitted each step of the tweening. Numeric Constants ----------------- - **TWEEN_PROCESS_FIXED** = **0** --- The :ref:`Tween` should use ``_fixed_process`` for timekeeping when this is enabled. - **TWEEN_PROCESS_IDLE** = **1** --- The :ref:`Tween` should use ``_process`` for timekeeping when this is enabled (default). - **TRANS_LINEAR** = **0** --- Means that the animation is interpolated linearly. - **TRANS_SINE** = **1** --- Means that the animation is interpolated using a sine wave. - **TRANS_QUINT** = **2** --- Means that the animation is interpolated with a quinary (to the power of 5) function. - **TRANS_QUART** = **3** --- Means that the animation is interpolated with a quartic (to the power of 4) function. - **TRANS_QUAD** = **4** --- Means that the animation is interpolated with a quadratic (to the power of 2) function. - **TRANS_EXPO** = **5** --- Means that the animation is interpolated with an exponential (some number to the power of x) function. - **TRANS_ELASTIC** = **6** --- Means that the animation is interpolated with elasticity, wiggling around the edges. - **TRANS_CUBIC** = **7** --- Means that the animation is interpolated with a cubic (to the power of 3) function. - **TRANS_CIRC** = **8** --- Means that the animation is interpolated with a function using square roots. - **TRANS_BOUNCE** = **9** --- Means that the animation is interpolated by bouncing at, but never surpassing, the end. - **TRANS_BACK** = **10** --- Means that the animation is interpolated backing out at edges. - **EASE_IN** = **0** --- Signifies that the interpolation should be focused in the beginning. - **EASE_OUT** = **1** --- Signifies that the interpolation should be focused in the end. - **EASE_IN_OUT** = **2** --- Signifies that the interpolation should be focused in both ends. - **EASE_OUT_IN** = **3** --- Signifies that the interpolation should be focused in both ends, but they should be switched (a bit hard to explain, try it for yourself to be sure). Description ----------- Node useful for animations with unknown start and end points, procedural animations, making one node follow another, and other simple behavior. Because it is easy to get it wrong, here is a quick usage example: :: var tween = get_node("Tween") tween.interpolate_property(get_node("Node2D_to_move"), "transform/pos", Vector2(0,0), Vector2(100,100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) tween.start() Some of the methods of this class require a property name. You can get the property name by hovering over the property in the inspector of the editor. Many of the methods accept ``trans_type`` and ``ease_type``. The first accepts an TRANS\_\* constant, and refers to the way the timing of the animation is handled (you might want to see ``http://easings.net/`` for some examples). The second accepts an EASE\_\* constant, and controls the where ``trans_type`` is applied to the interpolation (in the beginning, the end, or both). If you don't know which transision and easing to pick, you can try different TRANS\_\* constants with EASE_IN_OUT, and use the one that looks best. Member Function Description --------------------------- .. _class_Tween_follow_method: - :ref:`bool` **follow_method** **(** :ref:`Object` object, :ref:`String` method, :ref:`Variant` initial_val, :ref:`Object` target, :ref:`String` target_method, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** Follow ``method`` of ``object`` and apply the returned value on ``target_method`` of ``target``, beginning from ``initial_val`` for ``duration`` seconds, ``delay`` later. Methods are animated by calling them with consequitive values. ``trans_type`` accepts TRANS\_\* constants, and is the way the animation is interpolated, while ``ease_type`` accepts EASE\_\* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. .. _class_Tween_follow_property: - :ref:`bool` **follow_property** **(** :ref:`Object` object, :ref:`String` property, :ref:`Variant` initial_val, :ref:`Object` target, :ref:`String` target_property, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** Follow ``property`` of ``object`` and apply it on ``target_property`` of ``target``, beginning from ``initial_val`` for ``duration`` seconds, ``delay`` seconds later. Note that ``target:target_property`` would equal ``object:property`` at the end of the tween. ``trans_type`` accepts TRANS\_\* constants, and is the way the animation is interpolated, while ``ease_type`` accepts EASE\_\* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. .. _class_Tween_get_runtime: - :ref:`float` **get_runtime** **(** **)** const Returns the time needed for all tweens to end in seconds, measured from the start. Thus, if you have two tweens, one ending 10 seconds after the start and the other - 20 seconds, it would return 20 seconds, as by that time all tweens would have finished. .. _class_Tween_get_speed_scale: - :ref:`float` **get_speed_scale** **(** **)** const Returns the speed that has been set from editor GUI or :ref:`set_repeat`. .. _class_Tween_get_tween_process_mode: - :ref:`int` **get_tween_process_mode** **(** **)** const Returns the process mode that has been set from editor GUI or :ref:`set_tween_process_mode` .. _class_Tween_interpolate_callback: - :ref:`bool` **interpolate_callback** **(** :ref:`Object` object, :ref:`float` duration, :ref:`String` callback, :ref:`Variant` arg1=null, :ref:`Variant` arg2=null, :ref:`Variant` arg3=null, :ref:`Variant` arg4=null, :ref:`Variant` arg5=null **)** Call ``callback`` of ``object`` after ``duration``. ``arg1``-``arg5`` are arguments to be passed to the callback. .. _class_Tween_interpolate_deferred_callback: - :ref:`bool` **interpolate_deferred_callback** **(** :ref:`Object` object, :ref:`float` duration, :ref:`String` callback, :ref:`Variant` arg1=null, :ref:`Variant` arg2=null, :ref:`Variant` arg3=null, :ref:`Variant` arg4=null, :ref:`Variant` arg5=null **)** Call ``callback`` of ``object`` after ``times_in_sec`` on the main thread (similar to methog Object.call_deferred). [codearg1``-``arg5`` are arguments to be passed to the callback. .. _class_Tween_interpolate_method: - :ref:`bool` **interpolate_method** **(** :ref:`Object` object, :ref:`String` method, :ref:`Variant` initial_val, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** Animate ``method`` of ``object`` from ``initial_val`` to ``final_val`` for ``duration`` seconds, ``delay`` seconds later. Methods are animated by calling them with consecuitive values. ``trans_type`` accepts TRANS\_\* constants, and is the way the animation is interpolated, while ``ease_type`` accepts EASE\_\* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. .. _class_Tween_interpolate_property: - :ref:`bool` **interpolate_property** **(** :ref:`Object` object, :ref:`String` property, :ref:`Variant` initial_val, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** Animate ``property`` of ``object`` from ``initial_val`` to ``final_val`` for ``duration`` seconds, ``delay`` seconds later. ``trans_type`` accepts TRANS\_\* constants, and is the way the animation is interpolated, while ``ease_type`` accepts EASE\_\* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. .. _class_Tween_is_active: - :ref:`bool` **is_active** **(** **)** const Returns true if any tweens are currently running, and false otherwise. Note that this method doesn't consider tweens that have ended. .. _class_Tween_is_repeat: - :ref:`bool` **is_repeat** **(** **)** const Returns true if repeat has been set from editor GUI or :ref:`set_repeat`. .. _class_Tween_remove: - :ref:`bool` **remove** **(** :ref:`Object` object, :ref:`String` key=null **)** Stop animating and completely remove a tween, given its object and property/method pair. Passing empty String as key will remove all tweens for given object. .. _class_Tween_remove_all: - :ref:`bool` **remove_all** **(** **)** Stop animating and completely remove all tweens. .. _class_Tween_reset: - :ref:`bool` **reset** **(** :ref:`Object` object, :ref:`String` key=null **)** Resets a tween to the initial value (the one given, not the one before the tween), given its object and property/method pair. Passing empty String as key will reset all tweens for given object. .. _class_Tween_reset_all: - :ref:`bool` **reset_all** **(** **)** Resets all tweens to their initial values (the ones given, not those before the tween). .. _class_Tween_resume: - :ref:`bool` **resume** **(** :ref:`Object` object, :ref:`String` key=null **)** Continue animating a stopped tween, given its object and property/method pair. Passing empty String as key will resume all tweens for given object. .. _class_Tween_resume_all: - :ref:`bool` **resume_all** **(** **)** Continue animating all stopped tweens. .. _class_Tween_seek: - :ref:`bool` **seek** **(** :ref:`float` time **)** Seek the animation to the given ``time`` in seconds. .. _class_Tween_set_active: - void **set_active** **(** :ref:`bool` active **)** Activate/deactivate the tween. You can use this for pausing animations, though :ref:`stop_all` and :ref:`resume_all` might be more fit for this. .. _class_Tween_set_repeat: - void **set_repeat** **(** :ref:`bool` repeat **)** Make the tween repeat after all tweens have finished. .. _class_Tween_set_speed_scale: - void **set_speed_scale** **(** :ref:`float` speed **)** Set the speed multiplier of the tween. Set it to 1 for normal speed, 2 for two times nromal speed, and 0.5 for half of the normal speed. Setting it to 0 would pause the animation, but you might consider using :ref:`set_active` or :ref:`stop_all` and :ref:`resume_all` for this. .. _class_Tween_set_tween_process_mode: - void **set_tween_process_mode** **(** :ref:`int` mode **)** Set whether the Tween uses ``_process`` or ``_fixed_process`` (accepts TWEEN_PROCESS_IDLE and TWEEN_PROCESS_FIXED constants, respectively). .. _class_Tween_start: - :ref:`bool` **start** **(** **)** Start the tween node. You can define tweens both before and after this. .. _class_Tween_stop: - :ref:`bool` **stop** **(** :ref:`Object` object, :ref:`String` key=null **)** Stop animating a tween, given its object and property/method pair. Passing empty String as key will stop all tweens for given object. .. _class_Tween_stop_all: - :ref:`bool` **stop_all** **(** **)** Stop animating all tweens. .. _class_Tween_targeting_method: - :ref:`bool` **targeting_method** **(** :ref:`Object` object, :ref:`String` method, :ref:`Object` initial, :ref:`String` initial_method, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** Animate ``method`` of ``object`` from the value returned by ``initial.initial_method`` to ``final_val`` for ``duration`` seconds, ``delay`` seconds later. Methods are animated by calling them with consecuitive values. ``trans_type`` accepts TRANS\_\* constants, and is the way the animation is interpolated, while ``ease_type`` accepts EASE\_\* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. .. _class_Tween_targeting_property: - :ref:`bool` **targeting_property** **(** :ref:`Object` object, :ref:`String` property, :ref:`Object` initial, :ref:`String` initial_val, :ref:`Variant` final_val, :ref:`float` duration, :ref:`int` trans_type, :ref:`int` ease_type, :ref:`float` delay=null **)** Animate ``property`` of ``object`` from the current value of the ``initial_val`` property of ``initial`` to ``final_val`` for ``duration`` seconds, ``delay`` seconds later. ``trans_type`` accepts TRANS\_\* constants, and is the way the animation is interpolated, while ``ease_type`` accepts EASE\_\* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. .. _class_Tween_tell: - :ref:`float` **tell** **(** **)** const Returns the current time of the tween.