Chimera Posted November 15, 2014 Share Posted November 15, 2014 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.jsPhaser.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 More sharing options...
spencerTL Posted November 16, 2014 Share Posted November 16, 2014 There's a typo on your case 'action' a colon in the wrong place. I suspect that's it. Sir_Everard 1 Link to comment Share on other sites More sharing options...
Recommended Posts