Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Buttons not firing after switching back to menu state


FranekKimono
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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