Phaser has built-in methods that make it easy for us to transition from one Scene to another. For us to transition between Scenes we have to
.stop() the playing of a Scene and
.start() the next Scene.
To stop a Scene, call
Then, to start a Scene, call
.start() methods take in a string that has the value of a Scene’s key. Like the name of the methods imply,
.stop() will stop the Scene and
start() will start playing the Scene.
Let’s see this in action!
For our game, we want to start the next scene after a player clicks on the game screen.
StartScene class, there is an event handler in
'pointerup' events. Inside the callback of the event handler, call
Still inside the callback function, call
With this functionality in, players can click anywhere on the start screen and transition to playing the game!