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

 Share

  • Recently Browsing   0 members

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