A simple manager for tracking and updating game tween objects.
Normally accessed via the static FlxTween.globalManager
rather than being created separately.
Constructor
Methods
angle(?Sprite:FlxSprite, FromAngle:Float, ToAngle:Float, Duration:Float = 1, ?Options:Null<TweenOptions>):AngleTween
Tweens numeric value which represents angle. Shorthand for creating a AngleTween object, starting it and adding it to the TweenManager.
FlxTween.angle(Sprite, -90, 90, 2.0, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Sprite | Optional Sprite whose angle should be tweened. |
---|---|
FromAngle | Start angle. |
ToAngle | End angle. |
Duration | Duration of the tween. |
Options | A structure with tween options. |
Returns:
The added AngleTween object.
4.2.0
.cancelTweensOf(Object:Dynamic, ?FieldPaths:Array<String>):Void
Cancels all related tweens on the specified object.
Note: Any tweens with the specified fields are cancelled, if the tween has other properties they will also be cancelled.
Parameters:
Object | The object with tweens to cancel. |
---|---|
FieldPaths | Optional list of the tween field paths to search for. If null or empty, all tweens on the specified object are canceled. Allows dot paths to check child properties. |
4.9.0
.circularMotion(Object:FlxObject, CenterX:Float, CenterY:Float, Radius:Float, Angle:Float, Clockwise:Bool, DurationOrSpeed:Float = 1, UseDuration:Bool = true, ?Options:Null<TweenOptions>):CircularMotion
Create a new CircularMotion tween.
FlxTween.circularMotion(Object, 250, 250, 50, 0, true, 2, true, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object to move (FlxObject or FlxSpriteGroup) |
---|---|
CenterX | X position of the circle's center. |
CenterY | Y position of the circle's center. |
Radius | Radius of the circle. |
Angle | Starting position on the circle. |
Clockwise | If the motion is clockwise. |
DurationOrSpeed | Duration of the movement in seconds. |
UseDuration | Duration of the movement. |
Ease | Optional easer function. |
Options | A structure with tween options. |
Returns:
The CircularMotion object.
4.2.0
.color(?Sprite:FlxSprite, Duration:Float = 1, FromColor:FlxColor, ToColor:FlxColor, ?Options:Null<TweenOptions>):ColorTween
Tweens numeric value which represents color. Shorthand for creating a ColorTween object, starting it and adding it to a TweenPlugin.
FlxTween.color(Sprite, 2.0, 0x000000, 0xffffff, 0.0, 1.0, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Sprite | Optional Sprite whose color should be tweened. |
---|---|
Duration | Duration of the tween in seconds. |
FromColor | Start color. |
ToColor | End color. |
Options | A structure with tween options. |
Returns:
The added ColorTween object.
4.2.0
.completeAll():Void
Immediately updates all tweens that are not looping (type FlxTween.LOOPING
or FlxTween.PINGPONG
)
and active
through their endings, triggering their onComplete
callbacks.
Note: if they haven't yet begun, this will first trigger their onStart
callback.
Note: their onComplete
callbacks are triggered in the next frame.
To trigger them immediately, call FlxTween.globalManager.update(0);
after this function.
In no case should it trigger an onUpdate
callback.
4.2.0
.completeTweensOf(Object:Dynamic, ?FieldPaths:Array<String>):Void
Immediately updates all tweens on the specified object with the specified fields that
are not looping (type FlxTween.LOOPING
or FlxTween.PINGPONG
) and active
through
their endings, triggering their onComplete
callbacks.
Note: if they haven't yet begun, this will first trigger their onStart
callback.
Note: their onComplete
callbacks are triggered in the next frame.
To trigger them immediately, call FlxTween.globalManager.update(0);
after this function.
In no case should it trigger an onUpdate
callback.
Note: Any tweens with the specified fields are completed, if the tween has other properties they will also be completed.
Parameters:
Object | The object with tweens to complete. |
---|---|
FieldPaths | Optional list of the tween field paths to search for. If null or empty, all tweens on the specified object are completed. Allows dot paths to check child properties. |
4.9.0
.cubicMotion(Object:FlxObject, FromX:Float, FromY:Float, aX:Float, aY:Float, bX:Float, bY:Float, ToX:Float, ToY:Float, Duration:Float = 1, ?Options:Null<TweenOptions>):CubicMotion
Create a new CubicMotion tween.
FlxTween.cubicMotion(_sprite, 0, 0, 500, 100, 400, 200, 100, 100, 2, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object to move (FlxObject or FlxSpriteGroup) |
---|---|
FromX | X start. |
FromY | Y start. |
aX | First control x. |
aY | First control y. |
bX | Second control x. |
bY | Second control y. |
ToX | X finish. |
ToY | Y finish. |
Duration | Duration of the movement in seconds. |
Options | A structure with tween options. |
Returns:
The CubicMotion object.
4.2.0
.flicker(basic:FlxBasic, duration:Float = 1.0, period:Float = 0.08, ?options:Null<FlickerTweenOptions>):FlickerTween
Flickers the desired object
Parameters:
basic | The object to flicker |
---|---|
duration | Duration of the tween, in seconds |
period | How often, in seconds, the visibility cycles |
options | A structure with flicker and tween options |
5.7.0
.forEach(Function:FlxTween ‑> Void):Void
Applies a function to all tweens
Parameters:
Function | A function that modifies one tween at a time |
---|
4.2.0
.isFlickering(basic:FlxBasic):Bool
Whether the object is flickering via this manager
5.7.0
.linearMotion(Object:FlxObject, FromX:Float, FromY:Float, ToX:Float, ToY:Float, DurationOrSpeed:Float = 1, UseDuration:Bool = true, ?Options:Null<TweenOptions>):LinearMotion
Create a new LinearMotion tween.
FlxTween.linearMotion(Object, 0, 0, 500, 20, 5, false, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object to move (FlxObject or FlxSpriteGroup) |
---|---|
FromX | X start. |
FromY | Y start. |
ToX | X finish. |
ToY | Y finish. |
DurationOrSpeed | Duration (in seconds) or speed of the movement. |
UseDuration | Whether to use the previous param as duration or speed. |
Options | A structure with tween options. |
Returns:
The LinearMotion object.
4.2.0
.linearPath(Object:FlxObject, Points:Array<FlxPoint>, DurationOrSpeed:Float = 1, UseDuration:Bool = true, ?Options:Null<TweenOptions>):LinearPath
Create a new LinearPath tween.
FlxTween.linearPath(Object, [FlxPoint.get(0, 0), FlxPoint.get(100, 100)], 2, true, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object to move (FlxObject or FlxSpriteGroup) |
---|---|
Points | An array of at least 2 FlxPoints defining the path |
DurationOrSpeed | Duration (in seconds) or speed of the movement. |
UseDuration | Whether to use the previous param as duration or speed. |
Options | A structure with tween options. |
Returns:
The LinearPath object.
4.2.0
.num(FromValue:Float, ToValue:Float, Duration:Float = 1, ?Options:Null<TweenOptions>, ?TweenFunction:Float ‑> Void):NumTween
Tweens some numeric value. Shorthand for creating a NumTween, starting it and adding it to the TweenManager. Using it in conjunction with a TweenFunction requires more setup, but is faster than VarTween because it doesn't use Reflection.
function tweenFunction(s:FlxSprite, v:Float) { s.alpha = v; }
FlxTween.num(1, 0, 2.0, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT }, tweenFunction.bind(mySprite));
Trivia: For historical reasons, you can use either onUpdate or TweenFunction to accomplish the same thing, but TweenFunction gives you the updated Float as a direct argument.
Parameters:
FromValue | Start value. |
---|---|
ToValue | End value. |
Duration | Duration of the tween. |
Options | A structure with tween options. |
TweenFunction | A function to be called when the tweened value updates. It is recommended not to use an anonymous function if you are maximizing performance, as those will be compiled to Dynamics on cpp. |
Returns:
The added NumTween object.
4.2.0
.quadMotion(Object:FlxObject, FromX:Float, FromY:Float, ControlX:Float, ControlY:Float, ToX:Float, ToY:Float, DurationOrSpeed:Float = 1, UseDuration:Bool = true, ?Options:Null<TweenOptions>):QuadMotion
Create a new QuadMotion tween.
FlxTween.quadMotion(Object, 0, 100, 300, 500, 100, 2, 5, false, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object to move (FlxObject or FlxSpriteGroup) |
---|---|
FromX | X start. |
FromY | Y start. |
ControlX | X control, used to determine the curve. |
ControlY | Y control, used to determine the curve. |
ToX | X finish. |
ToY | Y finish. |
DurationOrSpeed | Duration (in seconds) or speed of the movement. |
UseDuration | Whether to use the previous param as duration or speed. |
Options | A structure with tween options. |
Returns:
The QuadMotion object.
4.2.0
.quadPath(Object:FlxObject, Points:Array<FlxPoint>, DurationOrSpeed:Float = 1, UseDuration:Bool = true, ?Options:Null<TweenOptions>):QuadPath
Create a new QuadPath tween.
FlxTween.quadPath(Object, [FlxPoint.get(0, 0), FlxPoint.get(200, 200), FlxPoint.get(400, 0)], 2, true, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object to move (FlxObject or FlxSpriteGroup) |
---|---|
Points | An array of at least 3 FlxPoints defining the path |
DurationOrSpeed | Duration (in seconds) or speed of the movement. |
UseDuration | Whether to use the previous param as duration or speed. |
Options | A structure with tween options. |
Returns:
The QuadPath object.
4.2.0
.shake(Sprite:FlxSprite, Intensity:Float = 0.05, Duration:Float = 1, Axes:FlxAxes = XY, ?Options:Null<TweenOptions>):ShakeTween
A simple shake effect for FlxSprite. Shorthand for creating a ShakeTween, starting it and adding it to the TweenManager.
FlxTween.shake(Sprite, 0.1, 2, FlxAxes.XY, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Sprite | Sprite to shake. |
---|---|
Intensity | Percentage representing the maximum distance that the sprite can move while shaking. |
Duration | The length in seconds that the shaking effect should last. |
Axes | On what axes to shake. Default value is |
Options | A structure with tween options. |
tween(Object:Dynamic, Values:Dynamic, Duration:Float = 1, ?Options:Null<TweenOptions>):VarTween
Tweens numeric public properties of an Object. Shorthand for creating a VarTween, starting it and adding it to the TweenManager.
FlxTween.tween(Object, { x: 500, y: 350, "scale.x": 2 }, 2.0, { ease: easeFunction, onStart: onStart, onUpdate: onUpdate, onComplete: onComplete, type: ONESHOT });
Parameters:
Object | The object containing the properties to tween. |
---|---|
Values | An object containing key/value pairs of properties and target values. |
Duration | Duration of the tween in seconds. |
Options | A structure with tween options. |
Returns:
The added VarTween object.
4.2.0
.