API Docs for: 1.4.0
Show:

Kiwi.Animations.Tween Class

Module: Tweens
Parent Module: Animations

Manages the tweening of properties/values on a single object. A Tween is the animation of a number between an initially value to and final value (that you specify). Note: When using a Tween you need to make sure that the Tween has been added to a TweenManager. You can either do this by creating the Tween via the Manager or alternatively using the 'add' method on the TweenManager. Otherwise the tween will not work.

Based on tween.js by sole. Converted to TypeScript and integrated into Kiwi. https://github.com/sole/tween.js

Constructor

Kiwi.Animations.Tween

(
  • object
  • game
)
Kiwi.Animations.Tween

Parameters:

  • object Any

    The object that this tween is taking affect on.

  • game Kiwi.Game

    The game that this tween is for.

Returns:

Kiwi.Animations.Tween:

This tween.

Methods

chain

(
  • tween
)
Kiwi.Animations.Tween public

Adds another tween that should start playing once tween has completed.

Parameters:

delay

(
  • amount
)
Kiwi.Animations.Tween public

Sets the amount of delay that the tween is to have before it starts playing.

Parameters:

  • amount Number

    The amount of time to delay the tween by.

easing

(
  • easing
)
Kiwi.Animations.Tween public

Sets the easing method that is to be used when animating this tween.

Parameters:

  • easing Function

    The easing function to use.

interpolation

(
  • interpolation
)
Kiwi.Animations.Tween public

[REQUIRES DESCRIPTION]

Parameters:

  • interpolation Any

objType

() String public

The type of object that this is.

Returns:

String:

"Tween"

onComplete

(
  • callback
  • context
)
public

Defines a method that is to be called when this tween is finished.

Parameters:

  • callback Function

    The method that is to be executed.

  • context Any

    The context the method is to have when called.

onStart

(
  • callback
  • context
)
Kiwi.Animations.Tween public

Adds a function that is to be executed when the tween start playing.

Parameters:

  • callback Function

    The function that is to be executed on tween start.

  • context Any

    The context that function is to have when called.

onUpdate

(
  • callback
  • context
)
public

Adds a function that is to be executed when this tween updates while it is playing.

Parameters:

  • callback Function

    The method that is to be executed.

  • context Any

    The context the method is to have when called.

setParent

(
  • value
)
public

Sets the game and the manager of this tween.

Parameters:

start

() public

Gets the initial values for the properties that it is to animate and starts the tween process.

stop

() public

Stops the Tween from running and removes it from the manager.

to

(
  • properties
  • [duration=1000]
  • [ease=null]
  • [autoStart=false]
)
Kiwi.Animations.Tween public

Sets up the various properties that define this tween. The ending position/properties for this tween, how long the tween should go for, easing method to use and if should start right way.

Parameters:

  • properties Object

    The ending location of the properties that you want to tween.

  • [duration=1000] Number optional

    The duration of the tween.

  • [ease=null] Any optional

    The easing method to be used. If not specifed then this will default to LINEAR.

  • [autoStart=false] Boolean optional

    If the tween should start right away.

update

(
  • time
)
Boolean public

The update loop is executed every frame whilst the tween is running.

Parameters:

  • time Number

Returns:

Boolean:

Whether the Tween is still running

Properties

_chainedTweens

Tween private

An array containing all of the tweens that are to be played when this one finishes.

_delayTime

Number private

The amount of time to delay the tween by. In Milliseconds.

_duration

Number private

The duration of the tween, in milliseconds.

_easingFunction

Function private

The easing function that is to be used while tweening.

Default: Kiwi.Tweens.Easing.Linear.None

_game

Kiwi.Game private

The game that this tween belongs to.

_interpolationFunction

Function private

[NEEDS DESCRIPTION]

Default: Kiwi.Utils.Interpolation.Linear

_manager

Kiwi.Animations.Tweens.TweenManager private

The manager that this tween belongs to.

_object

Any private

The object that this tween is affecting.

_onCompleteCallback

Function private

A method to be called when the tween finish's tweening.

Default: null

_onCompleteContext

Any private

The context that the onCompleteCallback should have when called.

Default: null

_onStartCallback

Function private

The method that is to be called when the tween starts playing.

Default: null

_onStartCallbackFired

Boolean private

A boolean indicating if the starting callback has been called or not.

Default: false

_onStartContext

Any private

The context that the _onStartCallback method is to be called in.

Default: null

_onUpdateCallback

Function private

A callback method that will be called each time the tween updates.

Default: null

_onUpdateContext

Any private

The context that the update callback has when called.

Default: null

_startTime

Number private

The time at which the tween started.

_valuesEnd

Object private

The end values of the properties that the tween is animating.

_valuesStart

Object private

The starting values of the properties that the tween is animating.

isRunning.

Boolean public

An indication of whether or not this tween is currently running.

Default: false

manager

Kiwi.Animations.Tweens.TweenManager private

Defined in src\animations\tweens\Tween.ts:77

Available since 1.2.0

The manager that this tween belongs to.

object

Any public

The object that this tween is affecting. If you change this, it will continue to tween, but any properties that are not on the new object will be discarded from the tween.