Tween

Smoothly animates a node's properties over time.

Tweens are useful for animations requiring a numerical property to be interpolated over a range of values. The name tween comes from in-betweening, an animation technique where you specify keyframes and the computer interpolates the frames that appear between them. Tween is more suited than AnimationPlayer for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a Tween node; it would be difficult to do the same thing with an AnimationPlayer node. Here is a brief usage example that makes a 2D node move smoothly between two positions:

More...
@GodotBaseClass
struct Tween {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
EaseType
enum EaseType
TransitionType
enum TransitionType
TweenProcessMode
enum TweenProcessMode

Functions

_removeByUid
void _removeByUid(long uid)
followMethod
bool followMethod(GodotObject object, String method, VariantArg2 initial_val, GodotObject target, String target_method, double duration, long trans_type, long ease_type, double delay)

Follows method of object and applies the returned value on target_method of target, beginning from initial_val for duration seconds, delay later. Methods are called with consecutive values. Use transitiontype for trans_type and easetype for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.

followProperty
bool followProperty(GodotObject object, NodePathArg1 property, VariantArg2 initial_val, GodotObject target, NodePathArg4 target_property, double duration, long trans_type, long ease_type, double delay)

Follows property of object and applies it on target_property of target, beginning from initial_val for duration seconds, delay seconds later. Use transitiontype for trans_type and easetype for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.

getRuntime
double getRuntime()

Returns the total time needed for all tweens to end. If you have two tweens, one lasting 10 seconds and the other 20 seconds, it would return 20 seconds, as by that time all tweens would have finished.

getSpeedScale
double getSpeedScale()
getTweenProcessMode
Tween.TweenProcessMode getTweenProcessMode()
interpolateCallback
bool interpolateCallback(GodotObject object, double duration, String callback, VariantArg3 arg1, VariantArg4 arg2, VariantArg5 arg3, VariantArg6 arg4, VariantArg7 arg5)

Calls callback of object after duration. arg1-arg5 are arguments to be passed to the callback.

interpolateDeferredCallback
bool interpolateDeferredCallback(GodotObject object, double duration, String callback, VariantArg3 arg1, VariantArg4 arg2, VariantArg5 arg3, VariantArg6 arg4, VariantArg7 arg5)

Calls callback of object after duration on the main thread (similar to GodotObject.callDeferred). arg1-arg5 are arguments to be passed to the callback.

interpolateMethod
bool interpolateMethod(GodotObject object, String method, VariantArg2 initial_val, VariantArg3 final_val, double duration, long trans_type, long ease_type, double delay)

Animates method of object from initial_val to final_val for duration seconds, delay seconds later. Methods are called with consecutive values. Use transitiontype for trans_type and easetype for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.

interpolateProperty
bool interpolateProperty(GodotObject object, NodePathArg1 property, VariantArg2 initial_val, VariantArg3 final_val, double duration, long trans_type, long ease_type, double delay)

Animates property of object from initial_val to final_val for duration seconds, delay seconds later. Setting the initial value to null uses the current value of the property. Use transitiontype for trans_type and easetype for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.

isActive
bool isActive()

Returns true if any tweens are currently running. Note: This method doesn't consider tweens that have ended.

isRepeat
bool isRepeat()
opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(Tween other)
opEquals
bool opEquals(typeof(null) n)
remove
bool remove(GodotObject object, String key)

Stops animation and removes a tween, given its object and property/method pair. By default, all tweens are removed, unless key is specified.

removeAll
bool removeAll()

Stops animation and removes all tweens.

reset
bool reset(GodotObject object, String key)

Resets a tween to its initial value (the one given, not the one before the tween), given its object and property/method pair. By default, all tweens are removed, unless key is specified.

resetAll
bool resetAll()

Resets all tweens to their initial values (the ones given, not those before the tween).

resume
bool resume(GodotObject object, String key)

Continues animating a stopped tween, given its object and property/method pair. By default, all tweens are resumed, unless key is specified.

resumeAll
bool resumeAll()

Continues animating all stopped tweens.

seek
bool seek(double time)

Sets the interpolation to the given time in seconds.

setActive
void setActive(bool active)

Activates/deactivates the tween. See also stopAll and resumeAll.

setRepeat
void setRepeat(bool repeat)
setSpeedScale
void setSpeedScale(double speed)
setTweenProcessMode
void setTweenProcessMode(long mode)
start
bool start()

Starts the tween. You can define animations both before and after this.

stop
bool stop(GodotObject object, String key)

Stops a tween, given its object and property/method pair. By default, all tweens are stopped, unless key is specified.

stopAll
bool stopAll()

Stops animating all tweens.

targetingMethod
bool targetingMethod(GodotObject object, String method, GodotObject initial, String initial_method, VariantArg4 final_val, double duration, long trans_type, long ease_type, double delay)

Animates method of object from the value returned by initial_method to final_val for duration seconds, delay seconds later. Methods are animated by calling them with consecutive values. Use transitiontype for trans_type and easetype for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.

targetingProperty
bool targetingProperty(GodotObject object, NodePathArg1 property, GodotObject initial, NodePathArg3 initial_val, VariantArg4 final_val, double duration, long trans_type, long ease_type, double delay)

Animates property of object from the current value of the initial_val property of initial to final_val for duration seconds, delay seconds later. Use transitiontype for trans_type and easetype for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.

tell
double tell()

Returns the current time of the tween.

toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

playbackProcessMode
Tween.TweenProcessMode playbackProcessMode [@property getter]
long playbackProcessMode [@property setter]

The tween's animation process thread. See tweenprocessmode.

playbackSpeed
double playbackSpeed [@property getter]
double playbackSpeed [@property setter]

The tween's speed multiplier. For example, set it to 1.0 for normal speed, 2.0 for two times normal speed, or 0.5 for half of the normal speed. A value of 0 pauses the animation, but see also setActive or stopAll for this.

repeat
bool repeat [@property getter]
bool repeat [@property setter]

If true, the tween loops.

Static functions

_new
Tween _new()

Construct a new instance of Tween. Note: use memnew!Tween instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

var tween = get_node("Tween") tween.interpolate_property($Node2D, "position", Vector2(0, 0), Vector2(100, 100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) tween.start()

Many methods require a property name, such as "position" above. You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using "property:component" (e.g. position:x), where it would only apply to that particular component. Many of the methods accept trans_type and ease_type. The first accepts an transitiontype constant, and refers to the way the timing of the animation is handled (see url=https://easings.net/easings.net/url for some examples). The second accepts an easetype constant, and controls where the trans_type is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different transitiontype constants with constant EASE_IN_OUT, and use the one that looks best. url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/tween_cheatsheet.pngTween easing and transition types cheatsheet/url

Meta