Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Wait for screen to startup


MTiger
 Share

Recommended Posts

In my game the player will create a character (TODO), then start the game.  The game starts by placing one tile on the board 

Right now I just have a GameController which is a phaser Scene

In the Game Controller I want to have instances to the board and the UI Menu so that I can communicate with the other scenes throughout the game 

The issue that I am currently having (and I think that it is because of JS single threaded nature) is that I need to wait for the Board's create method is complete before I can start calling the other methods, but scene.run does not start until Game.create is done (and I tried Game.preload)

So the question is there a way to wait / detect  until scene.run is finished?  I know that there are certain events that a scene triggers but can I hook into another objects events like on('Board:transitioncomplete',()=>)

Is there a cleaner way to structure the order of these events?

 

  create() {
    this.board = this.scene.get('Board');
    this.board = this.scene.get('UI');
    this.scene.run('Board');
    this.startGame();
  }

  startGame() {
    this.board.createRoom(0, 0, 'N');
    // this.UI.renderMessage({ message: 'Welcome to the dungeon', parameters: 'Param1' }, (param) => console.log(`Hello from Game with ${param}`));
  }

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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