Tween3
Extends: RefCounted
Description
In Godot 4, tweens cannot be resumed. But if you re-create them, the bindings are lost. So this class wraps a tween and offers a reset function.
Members
Signals
finished
signal finished()
Emitted when the tween finishes.
Parameters
None.
Methods
tween_interpolate_property
func tween_interpolate_property(tween: Tween, object: Object, property: NodePath, initial_val: Variant, final_val: Variant, duration: float, trans_type: int, ease_type: int, delay: float) -> bool
Interpolates a property on an object using a tween.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
tween |
|
The Tween instance to use. |
yes |
object |
|
The object whose property will be tweened. |
yes |
property |
|
The property to tween. |
yes |
initial_val |
|
The initial value of the property. |
yes |
final_val |
|
The final value of the property. |
yes |
duration |
|
The duration of the tween in seconds. |
yes |
trans_type |
|
The transition type (default 0). |
no |
ease_type |
|
The ease type (default 2). |
no |
delay |
|
The delay before starting the tween (default 0). |
no |
Returns
Returns True if the interpolation was set up successfully. (bool)
reset
func reset() -> void
Resets the tween, stopping and killing the current tween and creating a new one.
Parameters
None.
Returns
Returns nothing.
tween_method
func tween_method(method: Callable, from: Variant, to: Variant, duration: float) -> void
Adds a method tween to the tween sequence.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
method |
|
The method to tween. |
yes |
from |
|
The initial value. |
yes |
to |
|
The final value. |
yes |
duration |
|
The duration of the tween in seconds. |
yes |
Returns
Returns nothing.
interpolate_property
func interpolate_property(object: Object, property: NodePath, initial_val: Variant, final_val: Variant, duration: float, trans_type: int, ease_type: int, delay: float) -> bool
Interpolates a property on an object using the managed tween.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
object |
|
The object whose property will be tweened. |
yes |
property |
|
The property to tween. |
yes |
initial_val |
|
The initial value of the property. |
yes |
final_val |
|
The final value of the property. |
yes |
duration |
|
The duration of the tween in seconds. |
yes |
trans_type |
|
The transition type (default 0). |
no |
ease_type |
|
The ease type (default 2). |
no |
delay |
|
The delay before starting the tween (default 0). |
no |
Returns
Returns True if the interpolation was set up successfully. (bool)
play
func play() -> void
Plays the tween.
Parameters
None.
Returns
Returns nothing.
resume
func resume() -> void
Resumes the tween if it is valid.
Parameters
None.
Returns
Returns nothing.
pause
func pause() -> void
Pauses the tween.
Parameters
None.
Returns
Returns nothing.
stop
func stop() -> void
Stops the tween.
Parameters
None.
Returns
Returns nothing.
is_running
func is_running() -> Variant
True if the tween is running.
Parameters
None.
Returns
Returns true if the tween is running. True if the tween is running. (bool)
is_valid
func is_valid() -> Variant
True if the tween is valid.
Parameters
None.
Returns
Returns true if the tween is valid. True if the tween is valid. (bool)
get_total_elapsed_time
func get_total_elapsed_time() -> Variant
Gets the total elapsed time of the tween.
Parameters
None.
Returns
Returns the total elapsed time in seconds. (Variant)
get_duration
func get_duration() -> Variant
Gets the duration of the tween.
Parameters
None.
Returns
Returns the duration of the tween in seconds. (Variant)