Skip to content

Commit e57c700

Browse files
committed
The Gamepad.addCallbacks context parameter was never actually remembered, causing the callbacks to run in the wrong context (thanks @englercj phaserjs#1285)
1 parent c37173a commit e57c700

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Version 2.1.4 - "Bethal" - in development
105105
* Text.updateText was incorrectly increasing the size of the texture each time it was called (thanks @spayton #1261)
106106
* Polygon.contains now correctly calculates the result (thanks @pnstickne @BurnedToast #1267)
107107
* Setting Key.enabled = false while it is down did not reset the isDown state (thanks @pnstickne #1190 #1271)
108+
* The Gamepad.addCallbacks context parameter was never actually remembered, causing the callbacks to run in the wrong context (thanks @englercj #1285)
108109

109110

110111
For details about changes made in previous versions of Phaser see the full Change Log at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md

src/input/Gamepad.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ Phaser.Gamepad = function (game) {
136136
Phaser.Gamepad.prototype = {
137137

138138
/**
139-
* Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button up/axis change/float value buttons
139+
* Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button up/axis change/float value buttons.
140+
*
140141
* @method Phaser.Gamepad#addCallbacks
141142
* @param {Object} context - The context under which the callbacks are run.
142143
* @param {Object} callbacks - Object that takes six different callback methods:
@@ -152,6 +153,7 @@ Phaser.Gamepad.prototype = {
152153
this.onUpCallback = (typeof callbacks.onUp === 'function') ? callbacks.onUp : this.onUpCallback;
153154
this.onAxisCallback = (typeof callbacks.onAxis === 'function') ? callbacks.onAxis : this.onAxisCallback;
154155
this.onFloatCallback = (typeof callbacks.onFloat === 'function') ? callbacks.onFloat : this.onFloatCallback;
156+
this.callbackContext = context;
155157
}
156158

157159
},

0 commit comments

Comments
 (0)