phaser - v4.0.0-rc.4
    Preparing search index...

    The Scene Manager.

    The Scene Manager is a Game level system, responsible for creating, processing and updating all of the Scenes in a Game instance.

    You should not usually interact directly with the Scene Manager at all. Instead, you should use the Scene Plugin, which is available from every Scene in your game via the this.scene property.

    Using methods in this Scene Manager directly will break queued operations and can cause runtime errors. Instead, go via the Scene Plugin. Every feature this Scene Manager provides is also available via the Scene Plugin.

    Index

    Constructors

    Properties

    customViewports: number

    Do any of the Cameras in any of the Scenes require a custom viewport? If not we can skip scissor tests.

    game: Game

    The Game that this SceneManager belongs to.

    isBooted: boolean

    Has the Scene Manager properly started?

    isProcessing: boolean

    Is the Scene Manager actively processing the Scenes list?

    keys: Record<string, Scene>

    An object that maps the keys to the scene so we can quickly get a scene from a key without iteration.

    scenes: Scene[]

    The array in which all of the scenes are kept.

    systemScene: Scene

    This system Scene is created during bootQueue and is a default empty Scene that lives outside of the Scene list, but can be used by plugins and managers that need access to a live Scene, without being tied to one.

    Methods

    • 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

      • key: string

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

      • sceneConfig: SceneType

        The config for the Scene

      • OptionalautoStart: boolean

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

      • Optionaldata: object

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

      Returns Scene

    • Brings a Scene to the top of the Scenes list.

      This means it will render above all other Scenes.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to move.

      Returns this

    • Destroy this Scene Manager and all of its systems.

      This process cannot be reversed.

      This method is called automatically when a Phaser Game instance is destroyed.

      Returns void

    • Dumps debug information about each Scene to the developer console.

      Returns void

    • Retrieves a Scene by numeric index.

      Type Parameters

      Parameters

      • index: number

        The index of the Scene to retrieve.

      Returns T

    • Retrieves the numeric index of a Scene.

      Type Parameters

      Parameters

      • key: string | T

        The key of the Scene.

      Returns number

    • Retrieves a Scene based on the given key.

      If an actual Scene is passed to this method, it can be used to check if its currently within the Scene Manager, or not.

      Type Parameters

      Parameters

      • key: string | T

        The key of the Scene to retrieve.

      Returns T

    • Returns an array of all the current Scenes being managed by this Scene Manager.

      You can filter the output by the active state of the Scene and choose to have the array returned in normal or reversed order.

      Type Parameters

      Parameters

      • OptionalisActive: boolean

        Only include Scene's that are currently active? Default true.

      • OptionalinReverse: boolean

        Return the array of Scenes in reverse? Default false.

      Returns T

    • Determines whether a Scene is running.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to check.

      Returns boolean

    • Determines whether a Scene is paused.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to check.

      Returns boolean

    • Determines whether a Scene is sleeping.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to check.

      Returns boolean

    • Determines whether a Scene is visible.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to check.

      Returns boolean

    • Moves a Scene so it is immediately above another Scene in the Scenes list. If the Scene is already above the other, it isn't moved.

      This means it will render over the top of the other Scene.

      Type Parameters

      Parameters

      • keyA: string | T

        The Scene that Scene B will be moved above.

      • keyB: string | T

        The Scene to be moved.

      Returns this

    • Moves a Scene so it is immediately below another Scene in the Scenes list. If the Scene is already below the other, it isn't moved.

      This means it will render behind the other Scene.

      Type Parameters

      Parameters

      • keyA: string | T

        The Scene that Scene B will be moved below.

      • keyB: string | T

        The Scene to be moved.

      Returns this

    • Moves a Scene down one position in the Scenes list.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to move.

      Returns this

    • Moves a Scene up one position in the Scenes list.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to move.

      Returns this

    • Pauses the given Scene.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to pause.

      • Optionaldata: object

        An optional data object that will be passed to the Scene and emitted by its pause event.

      Returns this

    • Removes a Scene from the SceneManager.

      The Scene is removed from the local scenes array, it's key is cleared from the keys cache and Scene.Systems.destroy is then called on it.

      If the SceneManager is processing the Scenes when this method is called it will queue the operation for the next update sequence.

      Parameters

      • key: string

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

      Returns this

    • Resumes the given Scene.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to resume.

      • Optionaldata: object

        An optional data object that will be passed to the Scene and emitted by its resume event.

      Returns this

    • Runs the given Scene.

      If the given Scene is paused, it will resume it. If sleeping, it will wake it. If not running at all, it will be started.

      Use this if you wish to open a modal Scene by calling pause on the current Scene, then run on the modal Scene.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to run.

      • Optionaldata: object

        A data object that will be passed to the Scene on start, wake, or resume.

      Returns this

    • Sends a Scene to the back of the Scenes list.

      This means it will render below all other Scenes.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to move.

      Returns this

    • Puts the given Scene to sleep.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to put to sleep.

      • Optionaldata: object

        An optional data object that will be passed to the Scene and emitted by its sleep event.

      Returns this

    • Starts the given Scene, if it is not starting, loading, or creating.

      If the Scene is running, paused, or sleeping, it will be shutdown and then started.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to start.

      • Optionaldata: object

        Optional data object to pass to Scene.Settings and Scene.init, and Scene.create.

      Returns this

    • Stops the given Scene.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to stop.

      • Optionaldata: object

        Optional data object to pass to Scene.shutdown.

      Returns this

    • Swaps the positions of two Scenes in the Scenes list.

      Type Parameters

      Parameters

      • keyA: string | T

        The first Scene to swap.

      • keyB: string | T

        The second Scene to swap.

      Returns this

    • Sleeps one one Scene and starts the other.

      Type Parameters

      Parameters

      • from: string | T

        The Scene to sleep.

      • to: string | T

        The Scene to start.

      • Optionaldata: object

        Optional data object to pass to Scene.Settings and Scene.init, and Scene.create. It is only passed when the scene starts for the first time.

      Returns this

    • Updates the Scenes.

      Parameters

      • time: number

        Time elapsed.

      • delta: number

        Delta time from the last update.

      Returns void

    • Awakens the given Scene.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to wake up.

      • Optionaldata: object

        An optional data object that will be passed to the Scene and emitted by its wake event.

      Returns this