To add to this:
If you’re in JavaScript, you can “pause” the game using scenes. There are two functions in the game namespace to help with it:
game.pushScene()
game.popScene()
When you call pushScene()
, all of your sprites, tilemaps, and game update code will be hidden away and paused until you call popScene()
. Then, any new sprites you created in the meantime will get deleted and you’ll return to the paused game.
This is how the menu button works “under the hood”. You can also override the menu by registering a button event for it.