Skip to content

Commit 6906e6b

Browse files
committed
Hundreds more jsdocs completed.
1 parent 61c5f76 commit 6906e6b

14 files changed

Lines changed: 318 additions & 161 deletions

src/input/InputPlugin.js

Lines changed: 185 additions & 80 deletions
Large diffs are not rendered by default.

src/input/keyboard/combo/AdvanceKeyCombo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
* Return `true` if it reached the end of the combo, `false` if not.
1010
*
1111
* @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo
12+
* @private
1213
* @since 3.0.0
1314
*
14-
* @param {KeyboardEvent} event - [description]
15-
* @param {Phaser.Input.Keyboard.KeyCombo} combo - [description]
15+
* @param {KeyboardEvent} event - The native Keyboard Event.
16+
* @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to advance.
1617
*
1718
* @return {boolean} `true` if it reached the end of the combo, `false` if not.
1819
*/

src/input/keyboard/combo/KeyCombo.js

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,54 @@ var ResetKeyCombo = require('./ResetKeyCombo');
1212
/**
1313
* @callback KeyboardKeydownCallback
1414
*
15-
* @param {KeyboardEvent} event - [description]
15+
* @param {KeyboardEvent} event - The Keyboard Event.
1616
*/
1717

1818
/**
1919
* @typedef {object} KeyComboConfig
2020
*
21-
* @property {boolean} [resetOnWrongKey=true] - [description]
22-
* @property {number} [maxKeyDelay=0] - [description]
23-
* @property {boolean} [resetOnMatch=false] - [description]
24-
* @property {boolean} [deleteOnMatch=false] - [description]
21+
* @property {boolean} [resetOnWrongKey=true] - If they press the wrong key do we reset the combo?
22+
* @property {number} [maxKeyDelay=0] - The max delay in ms between each key press. Above this the combo is reset. 0 means disabled.
23+
* @property {boolean} [resetOnMatch=false] - If previously matched and they press the first key of the combo again, will it reset?
24+
* @property {boolean} [deleteOnMatch=false] - If the combo matches, will it delete itself?
2525
*/
2626

2727
/**
2828
* @classdesc
29-
* [description]
29+
* A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them
30+
* it will emit a `keycombomatch` event from the Keyboard Manager.
3031
*
31-
* `keys` argument can be:
32+
* The keys to be listened for can be defined as:
3233
*
33-
* A string (ATARI)
34+
* A string (i.e. 'ATARI')
3435
* An array of either integers (key codes) or strings, or a mixture of both
3536
* An array of objects (such as Key objects) with a public 'keyCode' property
3637
*
38+
* For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right)
39+
* you could pass the following array of key codes:
40+
*
41+
* ```javascript
42+
* this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true });
43+
*
44+
* this.input.keyboard.on('keycombomatch', function (event) {
45+
* console.log('Konami Code entered!');
46+
* });
47+
* ```
48+
*
49+
* Or, to listen for the user entering the word PHASER:
50+
*
51+
* ```javascript
52+
* this.input.keyboard.createCombo('PHASER');
53+
* ```
54+
*
3755
* @class KeyCombo
3856
* @memberOf Phaser.Input.Keyboard
3957
* @constructor
4058
* @since 3.0.0
4159
*
42-
* @param {Phaser.Input.Keyboard.KeyboardManager} keyboardManager - [description]
43-
* @param {(string|integer[]|object[])} keys - [description]
44-
* @param {KeyComboConfig} [config] - [description]
60+
* @param {Phaser.Input.Keyboard.KeyboardManager} keyboardManager - A reference to the Keyboard Manager.
61+
* @param {(string|integer[]|object[])} keys - The keys that comprise this combo.
62+
* @param {KeyComboConfig} [config] - A Key Combo configuration object.
4563
*/
4664
var KeyCombo = new Class({
4765

@@ -58,7 +76,7 @@ var KeyCombo = new Class({
5876
}
5977

6078
/**
61-
* [description]
79+
* A reference to the Keyboard Manager
6280
*
6381
* @name Phaser.Input.Keyboard.KeyCombo#manager
6482
* @type {Phaser.Input.Keyboard.KeyboardManager}
@@ -67,7 +85,7 @@ var KeyCombo = new Class({
6785
this.manager = keyboardManager;
6886

6987
/**
70-
* [description]
88+
* A flag that controls if this Key Combo is actively processing keys or not.
7189
*
7290
* @name Phaser.Input.Keyboard.KeyCombo#enabled
7391
* @type {boolean}
@@ -77,7 +95,7 @@ var KeyCombo = new Class({
7795
this.enabled = true;
7896

7997
/**
80-
* [description]
98+
* An array of the keycodes that comprise this combo.
8199
*
82100
* @name Phaser.Input.Keyboard.KeyCombo#keyCodes
83101
* @type {array}
@@ -119,7 +137,7 @@ var KeyCombo = new Class({
119137
* The current index of the key being waited for in the 'keys' string.
120138
*
121139
* @name Phaser.Input.Keyboard.KeyCombo#index
122-
* @type {number}
140+
* @type {integer}
123141
* @default 0
124142
* @since 3.0.0
125143
*/
@@ -185,7 +203,7 @@ var KeyCombo = new Class({
185203
this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0);
186204

187205
/**
188-
* If previously matched and they press Key 1 again, will it reset?
206+
* If previously matched and they press the first key of the combo again, will it reset?
189207
*
190208
* @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch
191209
* @type {boolean}
@@ -231,9 +249,10 @@ var KeyCombo = new Class({
231249
};
232250

233251
/**
234-
* [description]
252+
* The internal Key Down handler.
235253
*
236254
* @name Phaser.Input.Keyboard.KeyCombo#onKeyDown
255+
* @private
237256
* @type {KeyboardKeydownCallback}
238257
* @since 3.0.0
239258
*/
@@ -260,7 +279,7 @@ var KeyCombo = new Class({
260279
},
261280

262281
/**
263-
* [description]
282+
* Destroys this Key Combo and all of its references.
264283
*
265284
* @method Phaser.Input.Keyboard.KeyCombo#destroy
266285
* @since 3.0.0
@@ -271,7 +290,8 @@ var KeyCombo = new Class({
271290
this.keyCodes = [];
272291

273292
this.manager.off('keydown', this.onKeyDown);
274-
this.manager = undefined;
293+
294+
this.manager = null;
275295
}
276296

277297
});

src/input/keyboard/combo/ProcessKeyCombo.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ var AdvanceKeyCombo = require('./AdvanceKeyCombo');
1010
* Used internally by the KeyCombo class.
1111
*
1212
* @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo
13+
* @private
1314
* @since 3.0.0
1415
*
15-
* @param {KeyboardEvent} event - [description]
16-
* @param {Phaser.Input.Keyboard.KeyCombo} combo - [description]
16+
* @param {KeyboardEvent} event - The native Keyboard Event.
17+
* @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to be processed.
1718
*
18-
* @return {boolean} [description]
19+
* @return {boolean} `true` if the combo was matched, otherwise `false`.
1920
*/
2021
var ProcessKeyCombo = function (event, combo)
2122
{

src/input/keyboard/combo/ResetKeyCombo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Used internally by the KeyCombo class.
99
*
1010
* @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo
11+
* @private
1112
* @since 3.0.0
1213
*
1314
* @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset.

src/input/keyboard/keys/DownDuration.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
* @function Phaser.Input.Keyboard.DownDuration
1212
* @since 3.0.0
1313
*
14-
* @param {Phaser.Input.Keyboard.Key} key - [description]
15-
* @param {integer} [duration=50] - [description]
14+
* @param {Phaser.Input.Keyboard.Key} key - The Key object to test.
15+
* @param {integer} [duration=50] - The duration, in ms, within which the key must have been pressed down.
1616
*
17-
* @return {boolean} [description]
17+
* @return {boolean} `true` if the Key was pressed down within `duration` ms, otherwise `false`.
1818
*/
1919
var DownDuration = function (key, duration)
2020
{

src/input/keyboard/keys/JustDown.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66

77
/**
88
* The justDown value allows you to test if this Key has just been pressed down or not.
9+
*
910
* When you check this value it will return `true` if the Key is down, otherwise `false`.
11+
*
1012
* You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again.
11-
* This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop.
13+
* This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop.
1214
*
1315
* @function Phaser.Input.Keyboard.JustDown
1416
* @since 3.0.0
1517
*
16-
* @param {Phaser.Input.Keyboard.Key} key - [description]
18+
* @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just down or not.
1719
*
18-
* @return {boolean} [description]
20+
* @return {boolean} `true` if the Key was just pressed, otherwise `false`.
1921
*/
2022
var JustDown = function (key)
2123
{

src/input/keyboard/keys/JustUp.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66

77
/**
88
* The justUp value allows you to test if this Key has just been released or not.
9+
*
910
* When you check this value it will return `true` if the Key is up, otherwise `false`.
10-
* You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again.
11-
* This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop.
11+
*
12+
* You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again.
13+
* This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop.
1214
*
1315
* @function Phaser.Input.Keyboard.JustUp
1416
* @since 3.0.0
1517
*
16-
* @param {Phaser.Input.Keyboard.Key} key - [description]
18+
* @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just up or not.
1719
*
18-
* @return {boolean} [description]
20+
* @return {boolean} `true` if the Key was just released, otherwise `false`.
1921
*/
2022
var JustUp = function (key)
2123
{

src/input/keyboard/keys/ProcessKeyDown.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
* Used internally by the KeyboardManager.
99
*
1010
* @function Phaser.Input.Keyboard.ProcessKeyDown
11+
* @private
1112
* @since 3.0.0
1213
*
13-
* @param {Phaser.Input.Keyboard.Key} key - [description]
14-
* @param {KeyboardEvent} event - [description]
14+
* @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for.
15+
* @param {KeyboardEvent} event - The native Keyboard event.
1516
*
16-
* @return {Phaser.Input.Keyboard.Key} [description]
17+
* @return {Phaser.Input.Keyboard.Key} The Key that was processed.
1718
*/
1819
var ProcessKeyDown = function (key, event)
1920
{

src/input/keyboard/keys/ProcessKeyUp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
* Used internally by the KeyboardManager.
99
*
1010
* @function Phaser.Input.Keyboard.ProcessKeyUp
11+
* @private
1112
* @since 3.0.0
1213
*
13-
* @param {Phaser.Input.Keyboard.Key} key - [description]
14-
* @param {KeyboardEvent} event - [description]
14+
* @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for.
15+
* @param {KeyboardEvent} event - The native Keyboard event.
1516
*
16-
* @return {Phaser.Input.Keyboard.Key} [description]
17+
* @return {Phaser.Input.Keyboard.Key} The Key that was processed.
1718
*/
1819
var ProcessKeyUp = function (key, event)
1920
{

0 commit comments

Comments
 (0)