Tween class

Use the Tween class to animate the properties of a display object like x, y, scaleX, scaleY, alpha, rotation etc. The animation starts with the current value of the property and ends at a given target or delta value.

Use one of the predefined Transition functions to control the progress of the animation (linear, easeInQuadratic, easeInCubic, ...). If none of the predefined Transition functions fulfills your needs you can also define your own function (see TransitionFunction).

Examples:

var tween = new Tween(mySprite, 1.0, Transition.easeInCubic);
tween.delay = 0.5;
tween.animate.alpha.to(0.0);  // target value = 0.0
tween.animate.x.by(10.0);     // delta value = 10.0;
tween.animate.y.by(-10.0);    // delta value = -10.0;
tween.onComplete = () => print('completed');
stage.juggler.add(tween);

var sawtooth = Tween(mySprite, 1.0, (r) => (r * 4).remainder(1.0);
sawtooth.animate.y.to(10);
stage.juggler.add(sawtooth);

stage.juggler.addTween(mySprite, 1.0, Transition.easeInCubic)
  ..delay = 0.5
  ..animate.alpha.to(0.0);
Implemented types

Constructors

Tween(TweenObject tweenObject, num time, [TransitionFunction transition = Transition.linear])
Creates a new Tween for the specified TweenObject with a duration of time seconds.

Properties

animate TweenPropertyAccessor2D
Accessor for 2D properties like x, y, rotation, alpha and others which can be animated with this tween. Works for all display objects.
no setter
animate3D TweenPropertyAccessor3D
Accessor for 3D properties like offsetZ, rotationZ and others which can be animated with this tween. Works for all 3D display objects.
no setter
currentTime num
The current time of this Tween.
no setter
delay num
The delay this Tween waits until it starts animating.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isComplete bool
Indicates if this Tween is completed.
no setter
onComplete ← void Function()
The function that is called when this Tween is completed.
no getter
onStart ← void Function()
The function that is called when this Tween starts.
no getter
onUpdate ← void Function()
The function that is called every time this Tween updates the properties of the TweenObject.
no getter
roundToInt bool
Specifies if the values should be rounded to an integer.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
totalTime num
The total time of this Tween.
no setter
tweenObject TweenObject
The object that is tweened.
no setter

Methods

advanceTime(num time) bool
This method is called by the Juggler with the time past since the last call.
override
complete() → void
Advances this Tween to its end state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited