Tween
class Tween
Javascript Tweening Engine
Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equation
https://github.com/sole/Tween.js
author sole / http://soledadpenades.com
author mr.doob / http://mrdoob.com
author Robert Eisele / http://www.xarg.org
author Philippe / http://philippe.elsass.me
author Robert Penner / http://www.robertpenner.com/easing_terms_of_use.html
author Paul Lewis / http://www.aerotwist.com/
author lechecacharro
author Josh Faul / http://jocafa.com/
Constructor
new Tween(object: object) → {}
// add a tween to change the object pos.x and pos.y variable to 200 in 3 seconds
tween = new me.Tween(myObject.pos).to({
x: 200,
y: 200,
}, {
duration: 3000,
easing: me.Tween.Easing.Bounce.Out,
autoStart : true
}).onComplete(myFunc);
Name | Type | Description |
---|---|---|
object | object |
object on which to apply the tween |
Summary
Methods from Tween
Public Methods
chain(chainedTween: Tween) → {Tween}
chain the tween
Name | Type | Description |
---|---|---|
chainedTween | Tween |
Tween(s) to be chained |
Type | Description |
---|---|
Tween |
this instance for object chaining |
delay(amount: number) → {Tween}
delay the tween
Name | Type | Description |
---|---|---|
amount | number |
delay amount expressed in milliseconds |
Type | Description |
---|---|
Tween |
this instance for object chaining |
easing(easing: Easing) → {Tween}
set the easing function
Name | Type | Description |
---|---|---|
easing | Easing |
easing function |
Type | Description |
---|---|
Tween |
this instance for object chaining |
interpolation(interpolation: Interpolation) → {Tween}
set the interpolation function
Name | Type | Description |
---|---|---|
interpolation | Interpolation |
interpolation function |
Type | Description |
---|---|
Tween |
this instance for object chaining |
onComplete(onCompleteCallback: Function) → {Tween}
onComplete callback
Name | Type | Description |
---|---|---|
onCompleteCallback | Function |
callback |
Type | Description |
---|---|
Tween |
this instance for object chaining |
onStart(onStartCallback: Function) → {Tween}
onStart callback
Name | Type | Description |
---|---|---|
onStartCallback | Function |
callback |
Type | Description |
---|---|
Tween |
this instance for object chaining |
onUpdate(onUpdateCallback: Function) → {Tween}
onUpdate callback
Name | Type | Description |
---|---|---|
onUpdateCallback | Function |
callback |
Type | Description |
---|---|
Tween |
this instance for object chaining |
repeat(times: number) → {Tween}
Repeat the tween
Name | Type | Description |
---|---|---|
times | number |
amount of times the tween should be repeated |
Type | Description |
---|---|
Tween |
this instance for object chaining |
start(time: number) → {Tween}
start the tween
Name | Type | Attributes | Description |
---|---|---|---|
time | number |
<optional> |
the current time when the tween was started |
Type | Description |
---|---|
Tween |
this instance for object chaining |
stop() → {Tween}
stop the tween
Type | Description |
---|---|
Tween |
this instance for object chaining |
to(properties: object, options: object | number) → {Tween}
object properties to be updated and duration
Name | Type | Attributes | Description |
---|---|---|---|
properties | object |
hash of properties |
|
options | object | number |
<optional> |
object of tween properties, or a duration if a numeric value is passed |
options.duration | number |
<optional> |
tween duration |
options.easing | Easing |
<optional> |
easing function |
options.delay | number |
<optional> |
delay amount expressed in milliseconds |
options.yoyo | boolean |
<optional> |
allows the tween to bounce back to their original value when finished. To be used together with repeat to create endless loops. |
options.repeat | number |
<optional> |
amount of times the tween should be repeated |
options.interpolation | Interpolation |
<optional> |
interpolation function |
options.autoStart | boolean |
<optional> |
allow this tween to start automatically. Otherwise call me.Tween.start(). |
Type | Description |
---|---|
Tween |
this instance for object chaining |
yoyo(yoyo: boolean) → {Tween}
Allows the tween to bounce back to their original value when finished. To be used together with repeat to create endless loops.
Name | Type | Description |
---|---|---|
yoyo | boolean |
Type | Description |
---|---|
Tween |
this instance for object chaining |