The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines.
new TweenManager(scene)
name | type | description |
---|---|---|
scene | Phaser.Scene |
The Scene which owns this Tween Manager. |
The Systems object of the Scene which owns this Tween Manager.
The time scale of the Tween Manager.
This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager.
Create a Tween and add it to the active Tween list.
name | type | description |
---|---|---|
config | object | Phaser.Types.Tweens.TweenBuilderConfig |
The configuration object for the Tween. |
The created Tween.
Create a Number Tween and add it to the active Tween list.
name | type | description |
---|---|---|
config | Phaser.Types.Tweens.NumberTweenBuilderConfig |
The configuration object for the Number Tween. |
The created Number Tween.
Create a Tween and return it, but do NOT add it to the active or pending Tween lists.
name | type | description |
---|---|---|
config | object | Phaser.Types.Tweens.TweenBuilderConfig |
The configuration object for the Tween. |
The created Tween object.
Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists.
name | type | arguments | description |
---|---|---|---|
config | Phaser.Types.Tweens.TimelineBuilderConfig | <optional> |
The configuration object for the Timeline and its Tweens. |
The created Timeline object.
The Scene that owns this plugin is being destroyed. We need to shutdown and then kill off all external references.
Passes all Tweens to the given callback.
name | type | arguments | description |
---|---|---|---|
callback | function |
The function to call. |
|
scope | object | <optional> |
The scope ( |
args | * | <optional> |
The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. |
Add an existing tween into the active Tween list.
name | type | description |
---|---|---|
tween | Phaser.Tweens.Tween |
The Tween to add. |
This Tween Manager object.
Returns an array of all active Tweens and Timelines in the Tween Manager.
A new array containing references to all active Tweens and Timelines.
Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager.
The scale of the time delta, usually 1.
Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets.
Only the currently active tweens are tested. A tween that has completed and is awaiting removal will not be included in the results.
If you wish to also search pending tweens, use the includePending
flag.
name | type | arguments | Default | description |
---|---|---|---|---|
target | object | array |
The target to look for. Provide an array to look for multiple targets. |
||
includePending | boolean | <optional> | false |
Also check for pending tweens, not just active ones? |
A new array containing all Tweens and Timelines which affect the given target(s).
Checks if the given object is being affected by a playing Tween.
name | type | description |
---|---|---|
target | object |
target Phaser.Tweens.Tween object |
returns if target tween object is active or not
Stops all Tweens in this Tween Manager. They will be removed at the start of the frame.
This Tween Manager.
Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame.
name | type | description |
---|---|---|
target | object | array |
The target to look for. Provide an array to look for multiple targets. |
This Tween Manager.
Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't.
name | type | description |
---|---|---|
tween | Phaser.Tweens.Tween |
The Tween to check. |
This Tween Manager object.
Pauses all Tweens in this Tween Manager.
This Tween Manager.
Updates the Tween Manager's internal lists at the start of the frame.
This method will return immediately if no changes have been indicated.
Removes the given tween from the Tween Manager, regardless of its state (pending or active).
name | type | description |
---|---|---|
tween | Phaser.Tweens.Tween |
The Tween to be removed. |
This Tween Manager object.
Resumes all Tweens in this Tween Manager.
This Tween Manager.
Sets a new scale of the time delta for this Tween Manager.
The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens.
name | type | description |
---|---|---|
value | number |
The new scale of the time delta, where 1 is the normal speed. |
This Tween Manager.
The Scene that owns this plugin is shutting down. We need to kill and reset all internal properties as well as stop listening to Scene events.
Creates a Stagger function to be used by a Tween property.
The stagger function will allow you to stagger changes to the value of the property across all targets of the tween.
This is only worth using if the tween has multiple targets.
The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2 over the duration specified:
this.tweens.add({
targets: [ ... ],
scale: 0.2,
ease: 'linear',
duration: 1000,
delay: this.tweens.stagger(100)
});
The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering from the center out, using a cubic ease.
this.tweens.add({
targets: [ ... ],
scale: 0.2,
ease: 'linear',
duration: 1000,
delay: this.tweens.stagger(500, { grid: [ 10, 6 ], from: 'center', ease: 'cubic.out' })
});
name | type | description |
---|---|---|
value | number | Array.<number> |
The amount to stagger by, or an array containing two elements representing the min and max values to stagger between. |
config | Phaser.Types.Tweens.StaggerConfig |
The configuration object for the Stagger function. |
The stagger function.
Create a Tween Timeline and add it to the active Tween list.
name | type | arguments | description |
---|---|---|---|
config | Phaser.Types.Tweens.TimelineBuilderConfig | <optional> |
The configuration object for the Timeline and its Tweens. |
The created Timeline object.
Updates all Tweens and Timelines of the Tween Manager.
name | type | description |
---|---|---|
timestamp | number |
The current time in milliseconds. |
delta | number |
The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. |