Skip to main content
Version: Phaser v4.1.0

Scene

A base Phaser.Scene class which can be extended for your own use.

A Scene is the fundamental organizational unit in Phaser. Each Scene has its own display list, update loop, cameras, input handling, and loader. Multiple Scenes can run simultaneously (e.g., a game scene with a UI overlay scene). Scenes are managed by the SceneManager and communicate with each other via the ScenePlugin.

You can also define the optional methods init(), preload(), and create().

Constructor

new Scene([config])

Parameters

nametypeoptionaldescription
configstring | Phaser.Types.Scenes.SettingsConfigYesThe scene key or scene specific configuration settings.

Scope: static

Source: src/scene/Scene.js#L10
Since: 3.0.0

Public Members​

add​

add: Phaser.GameObjects.GameObjectFactory​

Description:

The Scene Game Object Factory.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L131
Since: 3.0.0


anims​

anims: Phaser.Animations.AnimationManager​

Description:

A reference to the global Animation Manager.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L54
Since: 3.0.0


cache​

cache: Phaser.Cache.CacheManager​

Description:

A reference to the global Cache.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L65
Since: 3.0.0


cameras​

cameras: Phaser.Cameras.Scene2D.CameraManager​

Description:

The Scene Camera Manager.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L120
Since: 3.0.0


children​

children: Phaser.GameObjects.DisplayList​

Description:

The Game Object Display List belonging to this Scene.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L164
Since: 3.0.0


data​

data: Phaser.Data.DataManager​

Description:

A Scene specific Data Manager Plugin.

See the registry property for the global Data Manager.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L186
Since: 3.0.0


events​

events: Phaser.Events.EventEmitter​

Description:

A Scene specific Event Emitter.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L109
Since: 3.0.0


game​

game: Phaser.Game​

Description:

A reference to the Phaser.Game instance.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L43
Since: 3.0.0


input​

input: Phaser.Input.InputPlugin​

Description:

The Scene Input Manager Plugin.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L199
Since: 3.0.0


lights​

lights: Phaser.GameObjects.LightsManager​

Description:

The Scene Lights Manager Plugin.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L175
Since: 3.0.0


load​

load: Phaser.Loader.LoaderPlugin​

Description:

The Scene Loader Plugin.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L210
Since: 3.0.0


make​

make: Phaser.GameObjects.GameObjectCreator​

Description:

The Scene Game Object Creator.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L142
Since: 3.0.0


matter​

matter: Phaser.Physics.Matter.MatterPhysics​

Description:

The Scene Matter Physics Plugin.

This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.

Source: src/scene/Scene.js#L254
Since: 3.0.0


physics​

physics: Phaser.Physics.Arcade.ArcadePhysics​

Description:

The Scene Arcade Physics Plugin.

This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.

Source: src/scene/Scene.js#L243
Since: 3.0.0


plugins​

plugins: Phaser.Plugins.PluginManager​

Description:

A reference to the global Plugin Manager.

The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install those plugins into Scenes as required.

Source: src/scene/Scene.js#L276
Since: 3.0.0


registry​

registry: Phaser.Data.DataManager​

Description:

A reference to the global Data Manager.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L76
Since: 3.0.0


renderer​

renderer: Phaser.Renderer.Canvas.CanvasRenderer, Phaser.Renderer.WebGL.WebGLRenderer​

Description:

A reference to the renderer instance Phaser is using, either Canvas Renderer or WebGL Renderer.

Source: src/scene/Scene.js#L288
Since: 3.50.0


scale​

scale: Phaser.Scale.ScaleManager​

Description:

A reference to the global Scale Manager.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L265
Since: 3.16.2


scene​

scene: Phaser.Scenes.ScenePlugin​

Description:

A reference to the Scene Manager Plugin.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L153
Since: 3.0.0


sound​

sound: Phaser.Sound.NoAudioSoundManager, Phaser.Sound.HTML5AudioSoundManager, Phaser.Sound.WebAudioSoundManager​

Description:

A reference to the Sound Manager.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L87
Since: 3.0.0


sys​

sys: Phaser.Scenes.Systems​

Description:

The Scene Systems. You must never overwrite this property, or all hell will break loose.

Source: src/scene/Scene.js#L34
Since: 3.0.0


textures​

textures: Phaser.Textures.TextureManager​

Description:

A reference to the Texture Manager.

This property will only be available if defined in the Scene Injection Map.

Source: src/scene/Scene.js#L98
Since: 3.0.0


time​

time: Phaser.Time.Clock​

Description:

The Scene Time and Clock Plugin.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L221
Since: 3.0.0


tweens​

tweens: Phaser.Tweens.TweenManager​

Description:

The Scene Tween Manager Plugin.

This property will only be available if defined in the Scene Injection Map and the plugin is installed.

Source: src/scene/Scene.js#L232
Since: 3.0.0


Public Methods​

update​

<instance> update(time, delta)​

Description:

Override this method in your own Scene subclass to implement per-frame game logic.

This method is called automatically once per game step while the scene is running. It is empty by default and is the primary place to put logic that needs to run every frame, such as updating game object positions, checking collisions, or reading input state.

Parameters:

nametypeoptionaldescription
timenumberNoThe current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
deltanumberNoThe delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.

Source: src/scene/Scene.js#L298
Since: 3.0.0