Pretty much as the subject line says: I’ve tried many, many (similar) ways of destroying an entire game instance, but no matter what I try I get Uncaught TypeError: displayList is null
My game is set up with multiple managed scenes; so there’s a BootScene, then a PreloaderScene, then a GameScene, then a RoomScene. Initially I thought it mattered what scene I ran the command from, but it doesn’t seem to - I always get the error above.
I’ve tried variations of GameScene.sys.game.destroy([true/false]); & GameScene.sys.game.runDestroy(), but no joy. I’m not sure if there’s some other kind of tidying up I need to do first?
I’m running Phaser 3.5.4 - here’s the full debug error:
All I’m aiming for is to completely unload the game from the browser (as it’s been completed and I want to show some stats in HTML), so if there’s another route, I’ll totally take it.
As in, what function did I run that resulted in that? That shows up in whatever destroy() I try, e.g. GameScene.sys.game.destroy(false);. The functions itself is in the Phaser core:
/**
* The Scene that owns this plugin is shutting down.
* We need to kill and reset all internal properties as well as stop listening to Scene events.
*
* @method Phaser.GameObjects.GameObjectFactory#shutdown
* @private
* @since 3.0.0
*/
shutdown: function ()
{
this.events.off(SceneEvents.SHUTDOWN, this.shutdown, this);
},
I had the same thought earlier - just tried it with 3.55.2 and the exact same result.
There’s a lot of code, and it’s a commercial development so I can’t share the source here; but it does make use of plenty of scenes, prefabs sprite atlases & audio sprites. All I can think is that maybe there’s something in that that’s somehow screwing up the logic.
The only other thing that came to mind is that when debugging the various game objects, I realised that I’m using this call:
GameScene.sys.game.destroy(true);
…however there’s no displayList under GameScene.sys.game; but there is one under just GameScene.sys. I don’t know if that’s an issue or not (for example, the root game object does’t have a displayList object either, but running game.destroy() from the console on that demo you posted results in the game freezing, so I’m guessing that’s not the issue?)
However, because I’ve got several scenes that are all stacked (BootScene, Preloader, Game, Level1, etc.), I find I have to destroy them all individually, and if I get to the scene where things are showing, e.g. FirstLevelScene.sys.game.destroy(), then it errors out as before.
It’s all under a globally-accessible game var, but running a straight game.destroy() from the console again results in the exact same error above
Yeah, that’s what I figured (in both instances) - the only reason I started drilling down was to try to isolate it. But yeah, I was wondering if I was hitting some edge case. For example I have emitters running, so whether it’s trying to do a cleanup of the scene to catch any stragglers, but by the time that comes around the scene is gone…?