pharma Posted December 8, 2015 Share Posted December 8, 2015 Hello, i can not figure out the simple problem here: Quiz.Game = function(game) {counter = 0;}Quiz.Game.prototype = {create: function() {button = this.add.sprite(100, 100, 'playbutton');button.inputEnabled = true;button.events.onInputDown.add(this.buttonDown, {num: 1});},buttonDown: function(num){counter++;console.log(counter);this.loadHighscores();},loadHighscores: function(){console.log('loadHighscores');}};It throws the error: Uncaught TypeError: this.loadHighscores is not a function What the **** is wrong with this.loadHighscores(); ? Thanks! Link to comment Share on other sites More sharing options...
rich Posted December 8, 2015 Share Posted December 8, 2015 You've missed out the context parameter:button.events.onInputDown.add(this.buttonDown, CONTEXT, {num: 1}); Link to comment Share on other sites More sharing options...
Recommended Posts