class flixel.tweens.FlxTween implements IFlxDestroyable

Available on all platforms

Class Fields

static var BACKWARD:Int

Backward Tween type, will play tween in reverse direction

static var LOOPING:Int

Looping Tween type, will restart immediately when it finishes.

static var ONESHOT:Int

Oneshot Tween type, will stop and remove itself from its core container when it finishes.

static var PERSIST:Int

Persistent Tween type, will stop when it finishes.

static var PINGPONG:Int

"To and from" Tween type, will play tween hither and thither

static var manager:TweenManager

The tweening plugin that handles all the tweens.

static function angle(?Sprite:FlxSprite = null, FromAngle:Float, ToAngle:Float, ?Duration:Float = 1, ?Options:TweenOptions = null):AngleTween

Tweens numeric value which represents angle. Shorthand for creating a AngleTween object, starting it and adding it to the TweenManager. * Example: FlxTween.angle(Sprite, -90, 90, 2.0, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

Sprite

Optional Sprite whose angle should be tweened. *

FromAngle

Start angle. *

ToAngle

End angle. *

Duration

Duration of the tween. *

Options

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The added AngleTween object.

static function circularMotion(Object:FlxObject, CenterX:Float, CenterY:Float, Radius:Float, Angle:Float, Clockwise:Bool, ?DurationOrSpeed:Float = 1, ?UseDuration:Bool = true, ?Options:TweenOptions = null):CircularMotion

Create a new CircularMotion tween. * Example: FlxTween.circularMotion(Object, 250, 250, 50, 0, true, 2, true { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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. *

Eease

Optional easer function. *

Options

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The CircularMotion object.

static function color(?Sprite:FlxSprite = null, ?Duration:Float = 1, FromColor:Int, ToColor:Int, ?FromAlpha:Float = 1, ?ToAlpha:Float = 1, ?Options:TweenOptions = null):ColorTween

Tweens numeric value which represents color. Shorthand for creating a ColorTween object, starting it and adding it to a TweenPlugin. * Example: FlxTween.color(Sprite, 2.0, 0x000000, 0xffffff, 0.0, 1.0, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

Sprite

Optional Sprite whose color should be tweened. *

Duration

Duration of the tween in seconds. *

FromColor

Start color. *

ToColor

End color. *

FromAlpha

Start alpha. *

ToAlpha

End alpha. *

Options

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The added ColorTween object.

static function cubicMotion(Object:FlxObject, FromX:Float, FromY:Float, aX:Float, aY:Float, bX:Float, bY:Float, ToX:Float, ToY:Float, ?Duration:Float = 1, ?Options:TweenOptions = null):CubicMotion

Create a new CubicMotion tween. * Example: FlxTween.cubicMotion(_sprite, 0, 0, 500, 100, 400, 200, 100, 100, 2, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The CubicMotion object.

static function linearMotion(Object:FlxObject, FromX:Float, FromY:Float, ToX:Float, ToY:Float, ?DurationOrSpeed:Float = 1, ?UseDuration:Bool = true, ?Options:TweenOptions = null):LinearMotion

Create a new LinearMotion tween. * Example: FlxTween.linearMotion(Object, 0, 0, 500, 20, 5, false, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The LinearMotion object.

static function linearPath(Object:FlxObject, Points:Array<FlxPoint>, ?DurationOrSpeed:Float = 1, ?UseDuration:Bool = true, ?Options:TweenOptions = null):LinearPath

Create a new LinearPath tween. * Example: FlxTween.linearPath(Object, [FlxPoint.get(0, 0), FlxPoint.get(100, 100)], 2, true, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The LinearPath object.

static function num(FromValue:Float, ToValue:Float, ?Duration:Float = 1, ?Options:TweenOptions = null, ?TweenFunction:Float ->Void = null):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. * * Example: * private function tweenFunction(s:FlxSprite, v:Float) { s.alpha = v; } * FlxTween.num(1, 0, 2.0, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }, tweenFunction.bind(mySprite)); * *

FromValue

Start value. *

ToValue

End value. *

Duration

Duration of the tween. *

Options

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

TweenFunction

A function to be called when the tweened value updates. It is recommended not to use an anonoymous * function if you are maximizing performance, as those will be compiled to Dynamics on cpp. *

returns

The added NumTween object.

static function quadMotion(Object:FlxObject, FromX:Float, FromY:Float, ControlX:Float, ControlY:Float, ToX:Float, ToY:Float, ?DurationOrSpeed:Float = 1, ?UseDuration:Bool = true, ?Options:TweenOptions = null):QuadMotion

Create a new QuadMotion tween. * Example: FlxTween.quadMotion(Object, 0, 100, 300, 500, 100, 2, 5, false, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The QuadMotion object.

static function quadPath(Object:FlxObject, Points:Array<FlxPoint>, ?DurationOrSpeed:Float = 1, ?UseDuration:Bool = true, ?Options:TweenOptions = null):QuadPath

Create a new QuadPath tween. * Example: FlxTween.quadPath(Object, [FlxPoint.get(0, 0), FlxPoint.get(200, 200), FlxPoint.get(400, 0)], 2, true, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The QuadPath object.

static function tween(Object:Dynamic, Values:Dynamic, ?Duration:Float = 1, ?Options:TweenOptions = null):VarTween

Tweens numeric public properties of an Object. Shorthand for creating a VarTween, starting it and adding it to the TweenManager. * Example: FlxTween.tween(Object, { x: 500, y: 350 }, 2.0, { ease: easeFunction, complete: onComplete, type: FlxTween.ONESHOT }); * *

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

An object containing key/value pairs of the following optional parameters: * type Tween type. * complete Optional completion callback function. * ease Optional easer function. * startDelay Seconds to wait until starting this tween, 0 by default. * loopDelay Seconds to wait between loops of this tween, 0 by default. *

returns

The added VarTween object.

Instance Fields

var executions:Int

How many times this tween has been executed / has finished so far - useful to * stop the LOOPING and PINGPONG types after a certain amount of time

var loopDelay:Float

Seconds to wait between loops of this tween, 0 by default

var startDelay:Float

Seconds to wait until starting this tween, 0 by default

var type:Int

function cancel():Void

Immediately stops the Tween and removes it from the * TweenManager without calling the complete callback.

function destroy():Void