Jump to content

javascript switch statement stops game.state.start from executing


Chimera
 Share

Recommended Posts

Not sure why this is happening, but when I perform a switch statement in a callback from the update method my 'play' state is not loaded from my preload state. When I comment out the switch statement and the affiliated callback in the update method then I am able to start my play.js state.

 

Error on preload.js

Phaser.StateManager - No state found with the key: Play 

 

 

Some of the code from play.js

  updatePlayerSprite: function() {    switch (this.playerState) {      case 'default':        if (this.game.input.activePointer.x < 360) {          this.player.setText(this.playerFrames.default.left);        } else if (this.game.input.activePointer.x > 600) {          this.player.setText(this.playerFrames.default.right);        } else {          this.player.setText(this.playerFrames.default.center);        }      break;      case 'battle':        if (this.game.input.activePointer.x < 360) {          this.player.setText(this.playerFrames.battle.left);        } else if (this.game.input.activePointer.x > 600) {          this.player.setText(this.playerFrames.battle.right);        } else {          this.player.setText(this.playerFrames.battle.center);        }      break;      case: 'action':        if (this.game.input.activePointer.x < 360) {          this.player.setText(this.playerFrames.action.left);        } else if (this.game.input.activePointer.x > 600) {          this.player.setText(this.playerFrames.action.right);        } else {          this.player.setText(this.playerFrames.action.center);        }      break;    }  },  updatePlayerSpriteClick: function() {    if (this.game.input.activePointer.isDown && this.playerActionWait === 0) {      this.playerState = 'action';      this.playerActionWait = 30;    } else if (this.playerActionWait > 0) {      this.playerActionWait = this.playerActionWait - 1;    } else if (this.playerActionWait === 0) {      this.playerState = 'default';    }  },  update: function() {    this.game.input.addMoveCallback(this.getPointerPosition, this);    this.updatePlayerSprite();    this.updatePlayerSpriteClick();  }

Anyone know any issues with switch statements and Phaser right now? 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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