You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added `enabled` getter; this resets the key (soft) and then disables they key
- Added `_enabled` property and updated internal usage
- Updated document for `reset`.
Copy file name to clipboardExpand all lines: src/input/Key.js
+39-10Lines changed: 39 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,10 @@ Phaser.Key = function (game, keycode) {
20
20
this.game=game;
21
21
22
22
/**
23
-
* @property {boolean} enabled - An enabled key processes its update and dispatches events. You can toggle this at run-time to disable a key without deleting it.
24
-
* @default
23
+
* The enabled state of the key - see `enabled`.
24
+
* @property {boolean} _enabled
25
25
*/
26
-
this.enabled=true;
26
+
this._enabled=true;
27
27
28
28
/**
29
29
* @property {object} event - Stores the most recent DOM event.
@@ -117,7 +117,7 @@ Phaser.Key.prototype = {
117
117
118
118
update: function(){
119
119
120
-
if(!this.enabled){return;}
120
+
if(!this._enabled){return;}
121
121
122
122
if(this.isDown)
123
123
{
@@ -140,7 +140,7 @@ Phaser.Key.prototype = {
140
140
*/
141
141
processKeyDown: function(event){
142
142
143
-
if(!this.enabled){return;}
143
+
if(!this._enabled){return;}
144
144
145
145
this.event=event;
146
146
@@ -171,7 +171,7 @@ Phaser.Key.prototype = {
171
171
*/
172
172
processKeyUp: function(event){
173
173
174
-
if(!this.enabled){return;}
174
+
if(!this._enabled){return;}
175
175
176
176
this.event=event;
177
177
@@ -190,11 +190,13 @@ Phaser.Key.prototype = {
190
190
},
191
191
192
192
/**
193
-
* 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
194
-
* associated with the onDown and onUp events and nulls the onHoldCallback if set.
193
+
* Resets the state of this Key.
194
+
*
195
+
* This sets isDown to false, isUp to true, resets the time to be the current time, and _enables_ the key.
196
+
* In addition, if it is a "hard reset", it clears clears any callbacks associated with the onDown and onUp events and removes the onHoldCallback.
195
197
*
196
198
* @method Phaser.Key#reset
197
-
* @param {boolean} [hard=true] - A soft reset won't reset any events or callbacks that are bound to this Key. A hard reset will.
199
+
* @param {boolean} [hard=true] - A soft reset won't reset any events or callbacks; a hard reset will.
0 commit comments