Any way to reloading "game" from a previous instance?

Hello, I’m at the final step of my project and I have an issue.

I used Ionic 4 and Phaser 3.
I have a main page using Phaser which is an hub, and several others pages that are for mini games.

My issues here, is that my main page is really heavy (about 600x400 tiles with 3 layers of details), and them, take too much time to load when you come back often.

Once loaded, when i quit this main page, is there a way to fast reloading without recreating the “game”.
(Maybe a way to injecting in a new “Phaser.Game()” previously created datas or something like that ?)

Hope it’s clear enough.

Thank you very much !

Re !
I got a way that does the trick, not sure it’s the cleanest way but it works.

// FIRST LOADING
// Create as usual
this.phaserGame = new Phaser.Game(this.config);
// Save the instance (you need to have access after)
oldInstance = this.phaserGame;


// SECOND LOADING
// - Check if oldInstance != undefined
// If so:
// Update canvas
document.getElementById("gameContainer").appendChild(oldInstance.canvas)
// Update game container
oldInstance.scale.parent = document.getElementById("gameContainer")

// Enjoy !
1 Like