Creates a tween with a target, duration (in seconds) and a transition function.
the object that you want to animate
the duration of the Tween (in seconds)
can be either a String (e.g. one of the constants defined in the Transitions class) or a function. Look up the 'Transitions' class for a documentation about the required signature.
The time that has passed since the tween was created (in seconds).
The delay before the tween is started (in seconds). @default 0
Indicates if the tween is finished.
Another tween that will be started (i.e. added to the same juggler) as soon as this tween is completed.
A that will be called when the tween is complete.
The arguments that will be passed to the 'onComplete' function.
A that will be called each time the tween finishes one repetition (except the last, which will trigger 'onComplete').
The arguments that will be passed to the 'onRepeat' function.
A that will be called when the tween starts (after a possible delay).
The arguments that will be passed to the 'onStart' function.
A that will be called each time the tween is advanced.
The arguments that will be passed to the 'onUpdate' function.
The current progress between 0 and 1, as calculated by the transition function.
The number of times the tween will be executed. Set to '0' to tween indefinitely. @default 1
The amount of time to wait between repeat cycles (in seconds). @default 0
Indicates if the tween should be reversed when it is repeating. If enabled, every second repetition will be reversed. @default false
Indicates if the numeric values should be cast to Integers. @default false
The target object that is animated.
The total time the tween will take per repetition (in seconds).
The transition method used for the animation. @see Transitions
The actual transition used for the animation.
Registers an event listener at a certain object.
Animates the property of the target to a certain value. You can call this method multiple times on one tween.
Some property types are handled in a special way:
color
or Color
,
it will be treated as an unsigned integer with a color value
(e.g. 0xff0000
for red). Each color channel will be animated
individually.#rgb
to the name.#rad
, the property is treated as an angle in radians,
making sure it always uses the shortest possible arc for the rotation.#deg
does the same for angles in degrees.Indicates if a property with the given name is being animated by this tween.
Dispatches an event to all objects that have registered listeners for its type. If an event with enabled 'bubble' property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.
Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.
Animates the 'alpha' property of an object to a certain target value.
The end value a certain property is animated to. Throws an ArgumentError if the property is not being animated.
If called with one argument, figures out if there are any listeners registered for the given event type. If called with two arguments, also determines if a specific listener is registered.
Animates the 'x' and 'y' properties of an object simultaneously.
Removes an event listener from the object.
Removes all event listeners with a certain type, or all of them if type is null. Be careful when removing all event listeners: you never know who else was listening.
Resets the tween to its default values. Useful for pooling tweens.
Animates the 'rotation' property of an object to a certain target value, using the smallest possible arc. 'type' may be either 'rad' or 'deg', depending on the unit of measurement.
Animates the 'scaleX' and 'scaleY' properties of an object simultaneously.
Generated using TypeDoc
A Tween animates numeric properties of objects. It uses different transition functions to give the animations various styles.
The primary use of this class is to do standard animations like movement, fading, rotation, etc. But there are no limits on what to animate; as long as the property you want to animate is numeric (
int, uint, Number
), the tween can handle it. For a list of available Transition types, look at the "Transitions" class.Here is an example of a tween that moves an object to the right, rotates it, and fades it out:
Note that the object is added to a juggler at the end of this sample. That's because a tween will only be executed if its "advanceTime" method is executed regularly - the juggler will do that for you, and will remove the tween when it is finished.
@see Juggler @see Transitions