I have a main scene with a number of sub-scenes (story dialog and mini-games). I’ve created a number of zones in my tile map to trigger the story scenes and mini-games. I’m having a couple of issues. When the player hits the zone the story starts as expected. However, when returning to the main scene.wake('thescene')
the player is still moving, likely because they were pressing the key to move when the entered the zone. The player will stop after the up button is pressed and released, then the scene carries on as normal.
-
How to I cancel the user input prior to launching the new scene.
-
How can can set the player position to a specified location (exit point) when the main scene loads.
The new position is saved in the object layer of the map, so I just wanted to pass a data package back notifying the main scene of the exit point. this.scene.wake('mainscene', { exitpoint: 'theexit'})
Where is the data accessed on the main scene, like what method is called when it wakes up?
Here is the callback on overlap for the zone to trigger the new scene:
() => {
if(this.player.data.values.entrance) return;
this.player.body.setVelocityY(0);
this.player.body.setVelocityX(0);
this.player.setData('entrance', 'complete');
this.scene.launch('story', { stage: 'entrance'});
this.scene.sleep();
}
When the child scene exits, I do something like this:
this.scene.stop();
this.scene.wake('mainscene', { exit: 'bumpercars_exit' });
Is there a better pattern to follow?