Why is my Scene's Display List null?

Hello.

I’ve noticed that, for some reason, when I enter a scene of type ShadowMatchingTutorial (a custom type created by my co-worker) for the first time, everything works fine. However, when I later instantiate another ShadowMatchingTutorial scene with a different key, add it to the Scene Manager, and start that scene, it doesn’t work.

Specifically, this scene is one that starts with a character delivering dialogue, which in our game, is represented with bitmap text. When I enter the first scene, the text renders as expected. When I enter the second scene, which is supposed to render the same text, the text doesn’t render at the beginning. After some digging, I have determined that this is because the scene’s displayList property is null.

Why would that be? Does anyone have any idea? I’m completely flummoxed. I would love any help anyone could give me.

How are you adding the second scene?

I’m instantiating a new scene by calling the constructor, and then I’m calling “this.game.scene.add”, with the “autoStart” parameter set to “true”.

It’s normally null after a scene is destroyed/removed.

Interesting. What I’m doing is, I’m transitioning to a new scene, and then I’m destroying the scene I left. But we’re not attempting to add things to a scene after it’s destroyed; we’re adding something to a newly instantiated scene. Do you think it’s possible that destroying the previous scene somehow interferes with the newly created scene and sets its displayList to null?

I don’t think so.

Maybe try debugging this with phaser-plugin-scene-watcher.

Also try without transitions.

Thanks for recommending the Scene Watcher! It looks cool.

What do you mean by “try without transitions”?

If you’re using scene.transition() etc., try switching scenes without transitions to see if the problem still occurs.

I’m not using scene.transition(), but thanks for the idea!