Jump to content

How to access a scene after it's been started?


Recommended Posts

Hi Everyone,

I'm using the SceneManager to start a scene. I then want initialise other parts of my game when the scene has started and is is ready.

I've tried this (`game` is a new Phaser.Game(config)):



const titleScreen = game.scene.getScene("TitleScreen");


... but titleSceen is `null`, preventing me from attaching any event listeners to it. However, if I wrap it in setTimeout and wait for 100 ms, I can access it:


setTimeout(event => {
  const titleScreen = game.scene.getScene("TitleScreen")
  console.log("It works!: ", titleScreen)
}, 100);


This is a hack, of course. Is there some way to listen for a scene "ready" events globally like this? (outside of scene objects themselves?)

Hope that's clear..?






Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...