Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Scenes . Systems

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Scenes . Systems

The Scene Systems class.

This class is available from within a Scene under the property sys. It is responsible for managing all of the plugins a Scene has running, including the display list, and handling the update step and renderer. It also contains references to global systems belonging to Game.

Constructor:

new Systems(scene, config)

Parameters:

name type description
scene Phaser.Scene

The Scene that owns this Systems instance.

config string | Phaser.Types.Scenes.SettingsConfig

Scene specific configuration settings.

Since: 3.0.0
Source: src/scene/Systems.js (Line 17)

Members

Description:

A reference to the Scene's Game Object Factory.

Use this to quickly and easily create new Game Object's.

In the default set-up you can access this from within a Scene via the this.add property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 197)
Focus
Focus

Description:

A reference to the global Animations Manager.

In the default set-up you can access this from within a Scene via the this.anims property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 116)
Focus
Focus

Description:

A reference to the global Cache. The Cache stores all files bought in to Phaser via the Loader, with the exception of images. Images are stored in the Texture Manager.

In the default set-up you can access this from within a Scene via the this.cache property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 127)
Focus
Focus

Description:

A reference to the Scene's Camera Manager.

Use this to manipulate and create Cameras for this specific Scene.

In the default set-up you can access this from within a Scene via the this.cameras property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 210)
Focus
Focus
canvas: HTMLCanvasElement
Focus
Focus

Description:

A handy reference to the Scene canvas / context.

Type:
HTMLCanvasElement
Since: 3.0.0
Source: src/scene/Systems.js (Line 96)
Focus
Focus

Description:

The Scene Configuration object, as passed in when creating the Scene.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 78)
Focus
Focus
context: CanvasRenderingContext2D
Focus
Focus

Description:

A reference to the Canvas Rendering Context being used by the renderer.

Type:
CanvasRenderingContext2D
Since: 3.0.0
Source: src/scene/Systems.js (Line 105)
Focus
Focus

Description:

A reference to the Scene's Display List.

Use this to organize the children contained in the display list.

In the default set-up you can access this from within a Scene via the this.children property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 223)
Focus
Focus

Description:

A reference to the Scene's Event Manager.

Use this to listen for Scene specific events, such as pause and shutdown.

In the default set-up you can access this from within a Scene via the this.events property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 236)
Focus
Focus

Description:

The Facebook Instant Games Plugin.

Type:
Since: 3.12.0
Source: src/scene/Systems.js (Line 68)
Focus
Focus
game: Phaser.Game
Focus
Focus

Description:

A reference to the Phaser Game instance.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 48)
Focus
Focus

Description:

A reference to the Scene's Game Object Creator.

Use this to quickly and easily create new Game Object's. The difference between this and the Game Object Factory, is that the Creator just creates and returns Game Object instances, it doesn't then add them to the Display List or Update List.

In the default set-up you can access this from within a Scene via the this.make property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 249)
Focus
Focus

Description:

A reference to the global Plugins Manager.

In the default set-up you can access this from within a Scene via the this.plugins property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 139)
Focus
Focus

Description:

A reference to the global registry. This is a game-wide instance of the Data Manager, allowing you to exchange data between Scenes via a universal and shared point.

In the default set-up you can access this from within a Scene via the this.registry property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 150)
Focus
Focus

Description:

A reference to either the Canvas or WebGL Renderer that this Game is using.

Type:
Since: 3.17.0
Source: src/scene/Systems.js (Line 57)
Focus
Focus

Description:

A reference to the global Scale Manager.

In the default set-up you can access this from within a Scene via the this.scale property.

Type:
Since: 3.15.0
Source: src/scene/Systems.js (Line 162)
Focus
Focus
scene: Phaser.Scene
Focus
Focus

Description:

A reference to the Scene that these Systems belong to.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 39)
Focus
Focus

Description:

A reference to the Scene Manager Plugin.

Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, or pause or resume a Scene, or switch from this Scene to another.

In the default set-up you can access this from within a Scene via the this.scene property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 264)
Focus
Focus
<private> sceneUpdate: function
Focus
Focus

Description:

The Scene Update function.

This starts out as NOOP during init, preload and create, and at the end of create it swaps to be whatever the Scene.update function is.

Type:
function
Since: 3.10.0
Source: src/scene/Systems.js (Line 294)
Focus
Focus

Description:

The Scene Settings. This is the parsed output based on the Scene configuration.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 87)
Focus
Focus

Description:

A reference to the global Sound Manager.

In the default set-up you can access this from within a Scene via the this.sound property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 173)
Focus
Focus

Description:

A reference to the global Texture Manager.

In the default set-up you can access this from within a Scene via the this.textures property.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 184)
Focus
Focus

Description:

A reference to the Scene's Update List.

Use this to organize the children contained in the update list.

The Update List is responsible for managing children that need their preUpdate methods called, in order to process so internal components, such as Sprites with Animations.

In the default set-up there is no reference to this from within the Scene itself.

Type:
Since: 3.0.0
Source: src/scene/Systems.js (Line 278)
Focus
Focus

Methods

depthSort()
Focus
Focus

Description:

Immediately sorts the display list if the flag is set.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 421)
Focus
Focus
<private> destroy()
Focus
Focus

Description:

Destroy this Scene and send a destroy event all of its systems. A destroyed Scene cannot be restarted. You should not call this directly, instead use SceneManager.remove.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 770)
Focus
Focus
getData()
Focus
Focus

Description:

Returns any data that was sent to this Scene by another Scene.

The data is also passed to Scene.init and in various Scene events, but you can access it at any point via this method.

Type:
  • any
Examples:
Since: 3.22.0
Source: src/scene/Systems.js (Line 551)
Focus
Focus
<protected> init(game)
Focus
Focus

Description:

This method is called only once by the Scene Manager when the Scene is instantiated. It is responsible for setting up all of the Scene plugins and references. It should never be called directly.

Parameters:

name type description
game Phaser.Game

A reference to the Phaser Game instance.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 308)
Focus
Focus
<private> install(plugin)
Focus
Focus

Description:

Called by a plugin, it tells the System to install the plugin locally.

Parameters:

name type description
plugin array

An array of plugins to install into this Scene.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 344)
Focus
Focus
isActive()
Focus
Focus

Description:

Is this Scene running?

Returns:
Description:

true if this Scene is running, otherwise false.

Type:
  • boolean
Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 580)
Focus
Focus
isPaused()
Focus
Focus

Description:

Is this Scene paused?

Returns:
Description:

true if this Scene is paused, otherwise false.

Type:
  • boolean
Examples:
Since: 3.13.0
Source: src/scene/Systems.js (Line 593)
Focus
Focus
isSleeping()
Focus
Focus

Description:

Is this Scene sleeping?

Returns:
Description:

true if this Scene is asleep, otherwise false.

Type:
  • boolean
Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 567)
Focus
Focus
isTransitionIn()
Focus
Focus

Description:

Is this Scene currently transitioning in from another Scene?

Returns:
Description:

true if this Scene is transitioning in from another Scene, otherwise false.

Type:
  • boolean
Examples:
Since: 3.5.0
Source: src/scene/Systems.js (Line 632)
Focus
Focus
isTransitionOut()
Focus
Focus

Description:

Is this Scene currently transitioning out from itself to another Scene?

Returns:
Description:

true if this Scene is in transition to another Scene, otherwise false.

Type:
  • boolean
Examples:
Since: 3.5.0
Source: src/scene/Systems.js (Line 619)
Focus
Focus
isTransitioning()
Focus
Focus

Description:

Is this Scene currently transitioning out to, or in from another Scene?

Returns:
Description:

true if this Scene is currently transitioning, otherwise false.

Type:
  • boolean
Examples:
Since: 3.5.0
Source: src/scene/Systems.js (Line 606)
Focus
Focus
isVisible()
Focus
Focus

Description:

Is this Scene visible and rendering?

Returns:
Description:

true if this Scene is visible, otherwise false.

Type:
  • boolean
Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 645)
Focus
Focus
pause([data])
Focus
Focus

Description:

Pause this Scene. A paused Scene still renders, it just doesn't run ANY of its update handlers or systems.

Parameters:

name type arguments description
data object <optional>

A data object that will be passed in the 'pause' event.

Returns:
Description:

This Systems object.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 432)
Focus
Focus
queueDepthSort()
Focus
Focus

Description:

Force a sort of the display list on the next render.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 410)
Focus
Focus
render(renderer)
Focus
Focus

Description:

Called automatically by the Scene Manager. Instructs the Scene to render itself via its Camera Manager to the renderer given.

Parameters:

name type description
renderer Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer

The renderer that invoked the render call.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 389)
Focus
Focus
resume([data])
Focus
Focus

Description:

Resume this Scene from a paused state.

Parameters:

name type arguments description
data object <optional>

A data object that will be passed in the 'resume' event.

Returns:
Description:

This Systems object.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 461)
Focus
Focus
setActive(value, [data])
Focus
Focus

Description:

Set the active state of this Scene.

An active Scene will run its core update loop.

Parameters:

name type arguments description
value boolean

If true the Scene will be resumed, if previously paused. If false it will be paused.

data object <optional>

A data object that will be passed in the 'resume' or 'pause' events.

Returns:
Description:

This Systems object.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 676)
Focus
Focus
setVisible(value)
Focus
Focus

Description:

Sets the visible state of this Scene. An invisible Scene will not render, but will still process updates.

Parameters:

name type description
value boolean

true to render this Scene, otherwise false.

Returns:
Description:

This Systems object.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 658)
Focus
Focus
shutdown([data])
Focus
Focus

Description:

Shutdown this Scene and send a shutdown event to all of its systems. A Scene that has been shutdown will not run its update loop or render, but it does not destroy any of its plugins or references. It is put into hibernation for later use. If you don't ever plan to use this Scene again, then it should be destroyed instead to free-up resources.

Parameters:

name type arguments description
data object <optional>

A data object that will be passed in the 'shutdown' event.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 734)
Focus
Focus
sleep([data])
Focus
Focus

Description:

Send this Scene to sleep.

A sleeping Scene doesn't run its update step or render anything, but it also isn't shut down or has any of its systems or children removed, meaning it can be re-activated at any point and will carry on from where it left off. It also keeps everything in memory and events and callbacks from other Scenes may still invoke changes within it, so be careful what is left active.

Parameters:

name type arguments description
data object <optional>

A data object that will be passed in the 'sleep' event.

Returns:
Description:

This Systems object.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 489)
Focus
Focus
start(data)
Focus
Focus

Description:

Start this Scene running and rendering. Called automatically by the SceneManager.

Parameters:

name type description
data object

Optional data object that may have been passed to this Scene from another.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 701)
Focus
Focus
step(time, delta)
Focus
Focus

Description:

A single game step. Called automatically by the Scene Manager as a result of a Request Animation Frame or Set Timeout call to the main Game instance.

Parameters:

name type description
time number

The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now().

delta number

The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 363)
Focus
Focus
wake([data])
Focus
Focus

Description:

Wake-up this Scene if it was previously asleep.

Parameters:

name type arguments description
data object <optional>

A data object that will be passed in the 'wake' event.

Returns:
Description:

This Systems object.

Examples:
Since: 3.0.0
Source: src/scene/Systems.js (Line 520)
Focus
Focus