Kiwi.Animations.Tween Class
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
Parameters:
-
object
AnyThe object that this tween is taking affect on.
-
game
Kiwi.GameThe game that this tween is for.
Returns:
This tween.
Item Index
Methods
Methods
chain
-
tween
Adds another tween that should start playing once tween has completed.
Parameters:
-
tween
Kiwi.Animations.Tween
Returns:
delay
-
amount
Sets the amount of delay that the tween is to have before it starts playing.
Parameters:
-
amount
NumberThe amount of time to delay the tween by.
Returns:
easing
-
easing
Sets the easing method that is to be used when animating this tween.
Parameters:
-
easing
FunctionThe easing function to use.
Returns:
interpolation
-
interpolation
[REQUIRES DESCRIPTION]
Parameters:
-
interpolation
Any
Returns:
objType
()
String
public
The type of object that this is.
Returns:
"Tween"
onComplete
-
callback
-
context
Defines a method that is to be called when this tween is finished.
Parameters:
-
callback
FunctionThe method that is to be executed.
-
context
AnyThe context the method is to have when called.
onStart
-
callback
-
context
Adds a function that is to be executed when the tween start playing.
Parameters:
-
callback
FunctionThe function that is to be executed on tween start.
-
context
AnyThe context that function is to have when called.
Returns:
onUpdate
-
callback
-
context
Adds a function that is to be executed when this tween updates while it is playing.
Parameters:
-
callback
FunctionThe method that is to be executed.
-
context
AnyThe context the method is to have when called.
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]
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
ObjectThe ending location of the properties that you want to tween.
-
[duration=1000]
Number optionalThe duration of the tween.
-
[ease=null]
Any optionalThe easing method to be used. If not specifed then this will default to LINEAR.
-
[autoStart=false]
Boolean optionalIf the tween should start right away.
Returns:
update
-
time
The update loop is executed every frame whilst the tween is running.
Parameters:
-
time
Number
Returns:
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
_interpolationFunction
Function
private
[NEEDS DESCRIPTION]
Default: Kiwi.Utils.Interpolation.Linear
_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
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.