From a4ed94e039619f8a29e915cadf33a20708e37a78 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 1 Apr 2014 04:41:43 +0100 Subject: [PATCH] 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. --- README.md | 1 + src/input/Key.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ed59d14a..c114ab747 100644 --- a/README.md +++ b/README.md @@ -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 Phaser jshint process is now running on Travis (thanks @xtian, #656) * 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 diff --git a/src/input/Key.js b/src/input/Key.js index 6886b7e3d..b88770a81 100644 --- a/src/input/Key.js +++ b/src/input/Key.js @@ -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 */ @@ -188,6 +189,11 @@ Phaser.Key.prototype = { this.timeUp = this.game.time.now; this.duration = this.game.time.now - this.timeDown; + this.onDown.removeAll(); + this.onUp.removeAll(); + this.onHoldCallback = null; + this.onHoldContext = null; + }, /**