Raiper34 Posted July 14, 2015 Share Posted July 14, 2015 Hi, I am trying to pass parameter on click button action like thisthis.backMenu = this.game.add.button(this.game.world.centerX, 0 - this.game.world.centerY + this.menuBackground.height/4, 'resume', function() {this.backMenuClick(this)});But with this it does not work, when function is global and i do not use this, it works, but i need run selfs method of object... Can anybody help me please? Thanks Link to comment Share on other sites More sharing options...
gianthead Posted July 14, 2015 Share Posted July 14, 2015 You need to pass the callback context as a parameter to game.add.button: game.add.button(x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame,group) → {Phaser.Button} so in your case: this.backMenu = this.game.add.button(this.game.world.centerX, 0 - this.game.world.centerY + this.menuBackground.height/4, 'resume', function() {this.backMenuClick(this)}, this); Raiper34 1 Link to comment Share on other sites More sharing options...
Raiper34 Posted July 14, 2015 Author Share Posted July 14, 2015 Aha thanks Still somethink to learn Link to comment Share on other sites More sharing options...
Recommended Posts