Jump to content

Game States do not work as expected


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);

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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