PokéRogue
    Preparing search index...

    The Scene Plugin is the main interface to the Scene Manager and allows you to control any Scene running in your game. You should always use this plugin. By default, it is mapped to the Scene property this.scene. Meaning, from within a Scene, you can call methods such as this.scene.start().

    Note that nearly all methods in this class are run on a queue-basis and not immediately. For example, calling this.scene.launch('SceneB') will try to launch SceneB when the Scene Manager next updates, which is at the start of the game step. All operations are queued and run in the order in which they are invoked here.

    Index
    • Parameters

      • scene: Scene

        The Scene that this ScenePlugin belongs to.

      Returns ScenePlugin

    key: string

    The key of the Scene this ScenePlugin belongs to.

    manager: SceneManager

    The Game's SceneManager.

    scene: Scene

    The Scene that this ScenePlugin belongs to.

    settings: SettingsObject

    The settings of the Scene this ScenePlugin belongs to.

    systems: Systems

    The Scene Systems instance of the Scene that this ScenePlugin belongs to.

    transitionProgress: number

    If this Scene is currently transitioning to another, this holds the current percentage of the transition progress, between 0 and 1.

    • Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set.

      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 | null

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

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

      This means it will render above all other Scenes.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to move.

      Returns this

      This Scene Plugin instance.

    • 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 Scene to retrieve.

      Returns T

      The Scene.

    • Retrieves the numeric index of a Scene in the Scenes list.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to get the index of.

      Returns number

      The index of the Scene.

    • Return the status of the Scene.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to get the status from.

      Returns number

      The Scene status. This maps to the Phaser.Scene constants, such as Phaser.Scene.LOADING.

    • Checks if the given Scene is running or not.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to check.

      Returns boolean

      Whether the Scene is running, or null if no matching Scene was found.

    • Checks if the given Scene is paused or not.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to check.

      Returns boolean

      Whether the Scene is paused, or null if no matching Scene was found.

    • Checks if the given Scene is sleeping or not.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to check.

      Returns boolean

      Whether the Scene is sleeping, or null if no matching Scene was found.

    • Checks if the given Scene is visible or not.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to check.

      Returns boolean

      Whether the Scene is visible, or null if no matching Scene was found.

    • Launch the given Scene and run it in parallel with this one.

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to launch.

      • Optionaldata: object

        The Scene data.

      Returns this

      This Scene Plugin instance.

    • 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 to be above.

      • OptionalkeyB: string | T

        The Scene to be moved. If none is given it defaults to this Scene.

      Returns this

      This Scene Plugin instance.

    • 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 to be below.

      • OptionalkeyB: string | T

        The Scene to be moved. If none is given it defaults to this Scene.

      Returns this

      This Scene Plugin instance.

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

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to move.

      Returns this

      This Scene Plugin instance.

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

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to move.

      Returns this

      This Scene Plugin instance.

    • Pause the Scene - this stops the update step from happening but it still renders.

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to pause.

      • Optionaldata: object

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

      Returns this

      This Scene Plugin instance.

    • Removes a Scene from the SceneManager.

      The Scene is removed from the local scenes array, its 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.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to be removed.

      Returns this

      This Scene Plugin instance.

    • Restarts this Scene.

      This will happen at the next Scene Manager update, not immediately.

      Parameters

      • Optionaldata: object

        The Scene data. If no value is given it will not overwrite any previous data that may exist.

      Returns this

      This Scene Plugin instance.

    • Resume the Scene - starts the update loop again.

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to resume.

      • Optionaldata: object

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

      Returns this

      This Scene Plugin instance.

    • Runs the given Scene, but does not change the state of this Scene.

      This will happen at the next Scene Manager update, not immediately.

      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 and emitted in its start, wake, or resume events.

      Returns this

      This Scene Plugin instance.

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

      This means it will render below all other Scenes.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to move.

      Returns this

      This Scene Plugin instance.

    • Sets the active state of the given Scene.

      Type Parameters

      Parameters

      • value: boolean

        If true the Scene will be resumed. If false it will be paused.

      • Optionalkey: string | T

        The Scene to set the active state of.

      • Optionaldata: object

        An optional data object that will be passed to the Scene and emitted with its events.

      Returns this

      This Scene Plugin instance.

    • Sets the visible state of the given Scene.

      Type Parameters

      Parameters

      • value: boolean

        If true the Scene will be made visible. If false it will be hidden.

      • Optionalkey: string | T

        The Scene to set the visible state for.

      Returns this

      This Scene Plugin instance.

    • Makes the Scene sleep (no update, no render) but doesn't shutdown.

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to put to sleep.

      • Optionaldata: object

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

      Returns this

      This Scene Plugin instance.

    • Shutdown this Scene and run the given one.

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to start.

      • Optionaldata: object

        The Scene data. If no value is given it will not overwrite any previous data that may exist.

      Returns this

      This Scene Plugin instance.

    • Shutdown the Scene, clearing display list, timers, etc.

      This happens at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to stop.

      • Optionaldata: any

        Optional data object to pass to Scene.Systems.shutdown.

      Returns this

      This Scene Plugin instance.

    • Swaps the position of two scenes in the Scenes list.

      This controls the order in which they are rendered and updated.

      Type Parameters

      Parameters

      • keyA: string | T

        The first Scene to swap.

      • OptionalkeyB: string | T

        The second Scene to swap. If none is given it defaults to this Scene.

      Returns this

      This Scene Plugin instance.

    • Makes this Scene sleep then starts the Scene given.

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • key: string | T

        The Scene to start.

      • Optionaldata: any

        Optional data object to pass to either the Scene wake or start method.

      Returns this

      This Scene Plugin instance.

    • This will start a transition from the current Scene to the target Scene given.

      The target Scene cannot be the same as the current Scene.

      The transition will last for the duration specified in milliseconds.

      You can have the target Scene moved above or below this one in the display list.

      You can specify an update callback. This callback will be invoked every frame for the duration of the transition.

      This Scene can either be sent to sleep at the end of the transition, or stopped. The default is to stop.

      There are also 5 transition related events: This scene will emit the event transitionout when the transition begins, which is typically the frame after calling this method.

      The target Scene will emit the event transitioninit when that Scene's init method is called. It will then emit the event transitionstart when its create method is called. If the Scene was sleeping and has been woken up, it will emit the event transitionwake instead of these two, as the Scenes init and create methods are not invoked when a Scene wakes up.

      When the duration of the transition has elapsed it will emit the event transitioncomplete. These events are cleared of all listeners when the Scene shuts down, but not if it is sent to sleep.

      It's important to understand that the duration of the transition begins the moment you call this method. If the Scene you are transitioning to includes delayed processes, such as waiting for files to load, the time still counts down even while that is happening. If the game itself pauses, or something else causes this Scenes update loop to stop, then the transition will also pause for that duration. There are checks in place to prevent you accidentally stopping a transitioning Scene but if you've got code to override this understand that until the target Scene completes it might never be unlocked for input events.

      Parameters

      Returns boolean

      true if the transition was started, otherwise false.

    • Makes the Scene wake-up (starts update and render).

      This will happen at the next Scene Manager update, not immediately.

      Type Parameters

      Parameters

      • Optionalkey: string | T

        The Scene to wake up.

      • Optionaldata: object

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

      Returns this

      This Scene Plugin instance.