FranekKimono Posted August 13, 2015 Share Posted August 13, 2015 Hello Hive! I've implemented a selection menu for my game in which I create a few buttons, one of which starts the actual game. Game.SelectionMenu.prototype = { init:function(levelData){ this.levelData = levelData; }, create:function(){ var button = this.add.button(x, y, 'startButton', this.startGame, this); }, startGame:function(){ this.state.start('Game', true, false, this.levelData); } }The problem arises when I navigate back to the selection menu: ... navigateBack:function(){ this.state.start('SelectionMenu', true, false, this.levelData); } ...The button appears (and even animates) but no longer fires when pressed. Is there some way to reset the state? Or is there something I'm missing about destroying a state once you leave it. I've tried: this.state.restart but this doesn't seem to fix the issue. I'm working with Phaser 2.4.2. Altara Thanks in advance, guys! Link to comment Share on other sites More sharing options...
FranekKimono Posted August 15, 2015 Author Share Posted August 15, 2015 So it turns out I was using a mouse down callback function that - for whatever reason - was breaking the game. I removed: this.input.mouse.onMouseDown = function(){ .. }and used if (this.input.activePointer.isDown){ ... }in the update() function instead. Maybe someday someone wiser than myself will explain the reasoning behind this behaviour. Link to comment Share on other sites More sharing options...
tips4design Posted August 15, 2015 Share Posted August 15, 2015 I think you are supposed to do something like this.input.mouse.onMouseDown.add(callback) , not over-write the onMouseDown Link to comment Share on other sites More sharing options...
Recommended Posts