Key.reset now clears any callbacks associated with the onDown and onUp events and nulls the onHoldCallback if set. Key.reset is called by Keyboard.reset when changing state.

This commit is contained in:
photonstorm 2014-04-01 04:41:43 +01:00
parent 439cefd481
commit a4ed94e039
2 changed files with 8 additions and 1 deletions

View file

@ -73,6 +73,7 @@ Updated
* The State.update function (and thus the update of any sub-classed Sprites or other objects) is now called before Stage, Tweens, Sound, Input, etc (#662) * The State.update function (and thus the update of any sub-classed Sprites or other objects) is now called before Stage, Tweens, Sound, Input, etc (#662)
* The Phaser jshint process is now running on Travis (thanks @xtian, #656) * The Phaser jshint process is now running on Travis (thanks @xtian, #656)
* The Phaser Gruntfile is now split up into option tasks (thanks @xtian, #638) * The Phaser Gruntfile is now split up into option tasks (thanks @xtian, #638)
* Key.reset now clears any callbacks associated with the onDown and onUp events and nulls the onHoldCallback if set. Key.reset is called by Keyboard.reset when changing state.
New Features New Features

View file

@ -177,7 +177,8 @@ Phaser.Key.prototype = {
}, },
/** /**
* Resets the state of this Key. * Resets the state of this Key. This sets isDown to false, isUp to true, resets the time to be the current time and clears any callbacks
* associated with the onDown and onUp events and nulls the onHoldCallback if set.
* *
* @method Phaser.Key#reset * @method Phaser.Key#reset
*/ */
@ -188,6 +189,11 @@ Phaser.Key.prototype = {
this.timeUp = this.game.time.now; this.timeUp = this.game.time.now;
this.duration = this.game.time.now - this.timeDown; this.duration = this.game.time.now - this.timeDown;
this.onDown.removeAll();
this.onUp.removeAll();
this.onHoldCallback = null;
this.onHoldContext = null;
}, },
/** /**