Phaser API Documentation

  Version: 
add(key, sceneConfig, [autoStart], [data])

Description:

Adds a new Scene into the SceneManager. You must give each Scene a unique key by which you'll identify it.

The sceneConfig can be:

  • A Phaser.Scene object, or an object that extends it.
  • A plain JavaScript object
  • A JavaScript ES6 Class that extends Phaser.Scene
  • A JavaScript ES5 prototype based Class
  • A JavaScript function

If a function is given then a new Scene will be created by calling it.

Parameters:

name type arguments Default description
key string

A unique key used to reference the Scene, i.e. MainMenu or Level1.

sceneConfig function | Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig

The config for the Scene

autoStart boolean <optional> false

If true the Scene will be started immediately after being added.

data object <optional>

Optional data object. This will be set as Scene.settings.data and passed to Scene.init, and Scene.create.

Returns:
Description:

The added Scene, if it was added immediately, otherwise null.

Type:
Since: 3.0.0