Class: TweenManager

Phaser.Tweens. TweenManager

The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines.


new TweenManager(scene)

Parameters:
Name Type Description
scene Phaser.Scene

The Scene which owns this Tween Manager.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 15)

Members


scene :Phaser.Scene

The Scene which owns this Tween Manager.

Type:
Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 32)

systems :Phaser.Scenes.Systems

The Systems object of the Scene which owns this Tween Manager.

Type:
Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 41)

timeScale :number

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.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/tweens/TweenManager.js (Line 50)

Methods


add(config)

Create a Tween and add it to the active Tween list.

Parameters:
Name Type Description
config object

The configuration object for the Tween as per the Phaser.Tweens.Builders.TweenBuilder.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 204)
Returns:

The created Tween.

Type
Phaser.Tweens.Tween

addCounter(config)

Create a Tween and add it to the active Tween list.

Parameters:
Name Type Description
config object

The configuration object for the Number Tween as per the Phaser.Tweens.Builders.NumberTweenBuilder.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 244)
Returns:

The created Number Tween.

Type
Phaser.Tweens.Tween

create(config)

Create a Tween and return it, but do NOT add it to the active or pending Tween lists.

Parameters:
Name Type Description
config object

The configuration object for the Tween as per Phaser.Tweens.Builders.TweenBuilder.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 189)
Returns:

The created Tween object.

Type
Phaser.Tweens.Tween

createTimeline(config)

Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists.

Parameters:
Name Type Description
config object

The configuration object for the Timeline and its Tweens.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 150)
Returns:

The created Timeline object.

Type
Phaser.Tweens.Timeline

destroy()

The Scene that owns this plugin is being destroyed. We need to shutdown and then kill off all external references.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 675)

each(callback [, scope] [, args])

Passes all Tweens to the given callback.

Parameters:
Name Type Argument Description
callback function

The function to call.

scope object <optional>

The scope (this object) to call the function with.

args * <optional>
<repeatable>

The arguments to pass into the function. Its first argument will always be the Tween currently being iterated.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 410)

existing(tween)

Add an existing tween into the active Tween list.

Parameters:
Name Type Description
tween Phaser.Tweens.Tween

The Tween to add.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 225)
Returns:

This Tween Manager object.

Type
Phaser.Tweens.TweenManager

getAllTweens()

Returns an array of all active Tweens and Timelines in the Tween Manager.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 437)
Returns:

A new array containing references to all active Tweens and Timelines.

Type
Array.<Phaser.Tweens.Tween>

getGlobalTimeScale()

Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 458)
Returns:

The scale of the time delta, usually 1.

Type
number

getTweensOf(target)

Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets.

Parameters:
Name Type Description
target object | array

The target to look for. Provide an array to look for multiple targets.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 471)
Returns:

A new array containing all Tweens and Timelines which affect the given target(s).

Type
Array.<Phaser.Tweens.Tween>

isTweening(target)

Checks if the given object is being affected by a playing Tween.

Parameters:
Name Type Description
target object

target Phaser.Tweens.Tween object

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 519)
Returns:

returns if target tween object is active or not

Type
boolean

killAll()

Stops all Tweens in this Tween Manager. They will be removed at the start of the frame.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 547)
Returns:

This Tween Manager.

Type
Phaser.Tweens.TweenManager

killTweensOf(target)

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.

Parameters:
Name Type Description
target object | array

The target to look for. Provide an array to look for multiple targets.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 567)
See:
  • #getTweensOf
Returns:

This Tween Manager.

Type
Phaser.Tweens.TweenManager

makeActive(tween)

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.

Parameters:
Name Type Description
tween Phaser.Tweens.Tween

The Tween to check.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 377)
Returns:

This Tween Manager object.

Type
Phaser.Tweens.TweenManager

pauseAll()

Pauses all Tweens in this Tween Manager.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 591)
Returns:

This Tween Manager.

Type
Phaser.Tweens.TweenManager

preUpdate()

Updates the Tween Manager's internal lists at the start of the frame.

This method will return immediately if no changes have been indicated.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 265)

resumeAll()

Resumes all Tweens in this Tween Manager.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 611)
Returns:

This Tween Manager.

Type
Phaser.Tweens.TweenManager

setGlobalTimeScale(value)

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.

Parameters:
Name Type Description
value number

The new scale of the time delta, where 1 is the normal speed.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 631)
Returns:

This Tween Manager.

Type
Phaser.Tweens.TweenManager

shutdown()

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.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 650)

timeline(config)

Create a Tween Timeline and add it to the active Tween list/

Parameters:
Name Type Description
config object

The configuration object for the Timeline and its Tweens.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 165)
Returns:

The created Timeline object.

Type
Phaser.Tweens.Timeline

update(timestamp, delta)

Updates all Tweens and Timelines of the Tween Manager.

Parameters:
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.

Since: 3.0.0
Source: src/tweens/TweenManager.js (Line 345)