EgorkZe Posted November 25, 2014 Share Posted November 25, 2014 create() { this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.gravity.y = 700; this.platformArray = []; this.startGame(); this.game.input.keyboard.onUpCallback = Level1.prototype.upCallback; } upCallback(e){ if(e.keyCode == Phaser.Keyboard.X){ this.player.endSlide(); //I can't get access here }} How to get access for player's method? Link to comment Share on other sites More sharing options...
clark Posted November 25, 2014 Share Posted November 25, 2014 There is also a callbackContext which I guess defines the object where to find the method?this.game.input.keyboard.callbackContext = this;this.game.input.keyboard.onUpCallback = upCallback; Link to comment Share on other sites More sharing options...
rich Posted November 25, 2014 Share Posted November 25, 2014 Yup it needs a context. Or just use this:this.input.keyboard.addCallbacks(this, null, this.yourUpCallback);Which sets both in one call (the 'null' parameter is for an onDown callback). clark 1 Link to comment Share on other sites More sharing options...
Recommended Posts