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. Here is a brief usage example that causes a 2D node to 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, StringArg1 method, VariantArg2 initial_val, GodotObject target, StringArg4 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, StringArg2 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, StringArg2 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, StringArg1 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 that this method doesn't consider tweens that have ended.

isRepeat
bool isRepeat()
opAssign
Tween opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Tween other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
remove
bool remove(GodotObject object, StringArg1 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, StringArg1 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, StringArg1 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, StringArg1 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, StringArg1 method, GodotObject initial, StringArg3 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.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

playbackProcessMode
long playbackProcessMode [@property setter]

The tween's animation process thread. See tweenprocessmode. Default value: tweenProcessIdle.

playbackProcessMode
Tween.TweenProcessMode playbackProcessMode [@property getter]

The tween's animation process thread. See tweenprocessmode. Default value: tweenProcessIdle.

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()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
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
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
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. 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 http://easings.net/ for some examples). The second accepts an easetype 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 transition and easing to pick, you can try different transitiontype constants with EASE_IN_OUT, and use the one that looks best.

Meta