Jaspery Posted October 10, 2015 Share Posted October 10, 2015 Hello there, I was trying to switch states for my game with buttons. It was working for a moment and then now it throw me this error after I return Uncaught Error: Phaser.Signal: listener is a required param of add() and should be a Function. I looked into this link but it doesn't seem to fix despite try to call it differently Can anyone help me with this?RENAME_ME.MainMenu = function (game) {};var text;var counter = 0;RENAME_ME.MainMenu.prototype = {create: function () {this.game.stage.backgroundColor = '#cb191f';text = this.game.add.text(250, 16, '', {fill: '#fff'});var btn_startGame = this.game.add.button(this.game.world.centerX, this.game.world.centerY, 'cwa', this.toStartGame, this);btn_startGame.anchor.set(0.5);var btn_leaderboard = this.game.add.button(this.game.world.centerX, this.game.world.centerY + 100, 'cwa', this.toLeaderboard, this);btn_leaderboard.anchor.set(0.5);},update: function(){},toStartGame: function(){this.game.state.start("Game");},toLeaderboard: function(){this.game.state.start('Score');}}; Link to comment Share on other sites More sharing options...
jmp909 Posted October 12, 2015 Share Posted October 12, 2015 Can you try..., this.toStartGame.bind(this), this)And let me know if it works please? Link to comment Share on other sites More sharing options...
Jaspery Posted October 14, 2015 Author Share Posted October 14, 2015 Oddly enough, it does not work using apache server Now I switched to Yeoman phaser-generator and grunt, and it works fine :/ Thanks for the help though Link to comment Share on other sites More sharing options...
Recommended Posts