new Tween(object, game)
Tween constructor Create a new <code>Tween</code>.
Parameters:
| Name | Type | Description |
|---|---|---|
object |
object | Target object will be affected by this tween. |
game |
Phaser.Game | Current game instance. |
- Source:
Members
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running Game.
-
isRunning
-
- Default Value:
- false
- Source:
Properties:
Name Type Description isRunningboolean Description.
-
onComplete
-
- Source:
Properties:
Name Type Description onCompletePhaser.Signal Description.
-
onStart
-
- Source:
Properties:
Name Type Description onStartPhaser.Signal Description.
-
pendingDelete
-
- Default Value:
- false
- Source:
Properties:
Name Type Description pendingDeleteboolean If this tween is ready to be deleted by the TweenManager.
Methods
-
chain() → {Phaser.Tween}
-
You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion. You can pass as many tweens as you like to this function, they will each be chained in sequence.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
delay(amount) → {Phaser.Tween}
-
Sets a delay time before this tween will start.
Parameters:
Name Type Description amountnumber The amount of the delay in ms.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
easing(easing) → {Phaser.Tween}
-
Set easing function this tween will use, i.e. Phaser.Easing.Linear.None.
Parameters:
Name Type Description easingfunction The easing function this tween will use, i.e. Phaser.Easing.Linear.None.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
interpolation(interpolation) → {Phaser.Tween}
-
Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation.
Parameters:
Name Type Description interpolationfunction The interpolation function to use (Phaser.Math.linearInterpolation by default)
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
loop() → {Phaser.Tween}
-
Loop a chain of tweens
Usage: game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) .to({ x: 0 }, 1000, Phaser.Easing.Linear.None) .to({ y: 0 }, 1000, Phaser.Easing.Linear.None) .loop();
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
onCompleteCallback(callback) → {Phaser.Tween}
-
Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope.
Parameters:
Name Type Description callbackfunction The callback to invoke on completion.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
onStartCallback(callback) → {Phaser.Tween}
-
Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope.
Parameters:
Name Type Description callbackfunction The callback to invoke on start.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
onUpdateCallback(callback) → {Phaser.Tween}
-
Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope.
Parameters:
Name Type Description callbackfunction The callback to invoke each time this tween is updated.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
pause()
-
Pauses the tween.
- Source:
-
repeat(times) → {Phaser.Tween}
-
Sets the number of times this tween will repeat.
Parameters:
Name Type Description timesnumber How many times to repeat.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
resume()
-
Resumes a paused tween.
- Source:
-
start() → {Phaser.Tween}
-
Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
stop() → {Phaser.Tween}
-
Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
to(properties, duration, ease, autoStart, delay, repeat, yoyo) → {Phaser.Tween}
-
Configure the Tween
Parameters:
Name Type Description propertiesobject Properties you want to tween.
durationnumber Duration of this tween.
easefunction Easing function.
autoStartboolean Whether this tween will start automatically or not.
delaynumber Delay before this tween will start, defaults to 0 (no delay).
repeatboolean Should the tween automatically restart once complete? (ignores any chained tweens).
yoyoPhaser.Tween Description.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween
-
update(time) → {boolean}
-
Core tween update function called by the TweenManager. Does not need to be invoked directly.
Parameters:
Name Type Description timenumber A timestamp passed in by the TweenManager.
- Source:
Returns:
false if the tween has completed and should be deleted from the manager, otherwise true (still active).
- Type
- boolean
-
yoyo(yoyo) → {Phaser.Tween}
-
A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start. Used in combination with repeat you can create endless loops.
Parameters:
Name Type Description yoyoboolean Set to true to yoyo this tween.
- Source:
Returns:
Itself.
- Type
- Phaser.Tween