Phaser API Documentation

  Version: 
transition(config)

Description:

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

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:

name type description
config Phaser.Types.Scenes.SceneTransitionConfig

The transition configuration object.

Returns:
Description:

true is the transition was started, otherwise false.

Type:
  • boolean
Since: 3.5.0
Source: src/scene/ScenePlugin.js (Line 241)