Jump to content

Game States do not work as expected


BaltaXZ
 Share

Recommended Posts

Trying to understand state handling in Phaser. In this simple example, why does the following code log "Menu State" followed by "Game state" in the console? I would expect it to only write "Menu state", since I have not switched states anywhere in the code.

 

var game;
game = new Phaser.Game(800, 600);

game.state.add("Menu", state_menu);
game.state.add("Game", state_game);
game.state.start("Menu");


function state_menu() {

    console.log("Menu state");
    this.update = function () {

    }
}

function state_game() {

    console.log("Game state");
    this.update = function () {

    }

}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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