These affect the calling scene only.
Example:
this.scene.start()
method | calling scene | notes |
---|---|---|
pause | pause | |
remove | destroy | Queued during scene processing |
restart | shutdown?, start | Shutdown first only if RUNNING or PAUSED. |
resume | resume | |
sleep | sleep | |
start | shutdown?, start | Shutdown first only if RUNNING or PAUSED. |
stop | shutdown | |
wake | wake |
remove()
is queued while the Scene Manager is updating or rendering, or run immediately otherwise.
All other operations are queued always.
start()
and restart()
are identical when called without a key
argument.
These affect the target scene and may affect the calling scene.
Example:
this.scene.start('target')
method | calling scene | target scene | notes |
---|---|---|---|
launch | shutdown?, start | Target scene is shutdown first only if RUNNING or PAUSED. If the calling scene is also the target, nothing happens | |
pause | pause | ||
remove | destroy | Queued during scene processing | |
resume | resume | ||
run | shutdown?, start / wake / resume | Target scene is shutdown first only if RUNNING | |
sleep | sleep | ||
start | shutdown | shutdown?, start | Target scene is shutdown first only if RUNNING or PAUSED |
stop | shutdown | ||
switch | sleep | shutdown?, start / wake | Target scene is shutdown first only if RUNNING or PAUSED |
wake | wake |
remove()
is queued while the Scene Manager is updating or rendering, or run immediately otherwise.
All other operations are queued always.
restart()
never takes a key argument. Use launch('target')
instead.
Scene operations change a scene's state and trigger certain events.
Within a scene, you can listen to these events from this.events.
active
means a scene is updating its objects and plugins.
visible
means a scene is rendering its objects and plugins.
method | status | identity | active | visible | events |
---|---|---|---|---|---|
init | INIT | boot |
|||
start | START | yes | yes | start , ready |
|
pause | PAUSED | isPaused() | no | pause |
|
resume | RUNNING | isActive() | yes | resume |
|
sleep | SLEEPING | isSleeping() | no | no | sleep |
wake | RUNNING | isActive() | yes | yes | wake |
shutdown | SHUTDOWN | no | no | shutdown |
|
destroy | DESTROYED | no | no | destroy |
Table shows: SCENE STATUS, scene events
, scene methods
INIT | START | LOADING | CREATING | RUNNING | PAUSED | SLEEPING | SHUTDOWN | DESTROYED |
---|---|---|---|---|---|---|---|---|
boot |
||||||||
start |
(resume /wake ) |
pause |
sleep |
shutdown |
destroy |
|||
ready |
||||||||
init | ||||||||
create | ||||||||
preupdate |
preupdate |
|||||||
update |
update |
|||||||
update | ||||||||
postupdate |
postupdate |
|||||||
prerender |
prerender |
prerender |
||||||
render |
render |
render |
resume
is emitted only for PAUSED → RUNNING.wake
is emitted only for SLEEPING → RUNNING.
Hey Samme, feel free to chuck this table in I feel it adds some value to people trying to pass data around between scenes.
ScenePlugin methods usage with data
pause
resume
sleep
wake
shutdown
ready
ready
ready
ready
wake
orresume
orready
Start calls them in the order
ready
, init, create but will only call init and create if they are defined.Launch will call Start but on a different scene, and go through the same flow.
Restart will call stop on the scene without data, and call start again with data (and once again go through
ready
, init, create).Add will follow the same process as Start, but only if the scene is set to autostart or active in it's config, or will call them once the scene is started.
Run will emit an event depending on the initial state of the scene. If scene is asleep it will wake it and emit
wake
with data, or if paused it will resume it and emitresume
with data. *Otherwise if it has to start the scene, it will go through the start process with the data and emitready
then call init, create if they are defined.Sources:
Same as you
and:
https://github.com/photonstorm/phaser/blob/master/src/scene/typedefs/SceneInitCallback.js
https://github.com/photonstorm/phaser/blob/master/src/scene/typedefs/SceneCreateCallback.js