mirror of
https://github.com/photonstorm/phaser
synced 2024-09-20 06:21:54 +00:00
Merge pull request #5198 from samme/feature/KeyboardPlugin-removeAllKeys
Add KeyboardPlugin#removeAllKeys
This commit is contained in:
commit
6c7437cdc4
1 changed files with 32 additions and 0 deletions
|
@ -566,6 +566,38 @@ var KeyboardPlugin = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all Key objects created by _this_ Keyboard Plugin.
|
||||
*
|
||||
* @method Phaser.Input.Keyboard.KeyboardPlugin#removeAllKeys
|
||||
* @since 3.24.0
|
||||
*
|
||||
* @param {boolean} [destroy=false] - Call `Key.destroy` on each removed Key object?
|
||||
*
|
||||
* @return {this} This KeyboardPlugin object.
|
||||
*/
|
||||
removeAllKeys: function (destroy)
|
||||
{
|
||||
var keys = this.keys;
|
||||
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
{
|
||||
var key = keys[i];
|
||||
|
||||
if (key)
|
||||
{
|
||||
keys[i] = undefined;
|
||||
|
||||
if (destroy)
|
||||
{
|
||||
key.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new KeyCombo.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue