Skip to content

Commit fabaa49

Browse files
committed
jsdoc work
1 parent 3ba7397 commit fabaa49

6 files changed

Lines changed: 1126 additions & 92 deletions

File tree

src/input/InputManager.js

Lines changed: 242 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,175 @@ var InputManager = new Class({
1414

1515
initialize:
1616

17+
/**
18+
* [description]
19+
*
20+
* @class InputManager
21+
* @memberOf Phaser.Input
22+
* @constructor
23+
* @since 3.0.0
24+
*
25+
* @param {Phaser.Game} game - [description]
26+
* @param {object} config - [description]
27+
*/
1728
function InputManager (game, config)
1829
{
30+
/**
31+
* [description]
32+
*
33+
* @property {[type]} game
34+
* @since 3.0.0
35+
*/
1936
this.game = game;
2037

38+
/**
39+
* [description]
40+
*
41+
* @property {HTMLCanvasElement} canvas
42+
* @since 3.0.0
43+
*/
2144
this.canvas;
2245

46+
/**
47+
* [description]
48+
*
49+
* @property {object} config
50+
* @since 3.0.0
51+
*/
2352
this.config = config;
2453

54+
/**
55+
* [description]
56+
*
57+
* @property {boolean} enabled
58+
* @default true
59+
* @since 3.0.0
60+
*/
2561
this.enabled = true;
2662

63+
/**
64+
* [description]
65+
*
66+
* @property {[type]} events
67+
* @since 3.0.0
68+
*/
2769
this.events = new EventEmitter();
2870

29-
// Standard FIFO queue
71+
/**
72+
* Standard FIFO queue.
73+
*
74+
* @property {array} queue
75+
* @default []
76+
* @since 3.0.0
77+
*/
3078
this.queue = [];
3179

32-
// Listeners (will be based on config)
80+
/**
81+
* [description]
82+
*
83+
* @property {Phaser.Input.Keyboard.KeyboardManager} keyboard
84+
* @since 3.0.0
85+
*/
3386
this.keyboard = new Keyboard(this);
87+
88+
/**
89+
* [description]
90+
*
91+
* @property {Phaser.Input.Mouse.MouseManager} mouse
92+
* @since 3.0.0
93+
*/
3494
this.mouse = new Mouse(this);
95+
96+
/**
97+
* [description]
98+
*
99+
* @property {Phaser.Input.Touch.TouchManager} touch
100+
* @since 3.0.0
101+
*/
35102
this.touch = new Touch(this);
103+
104+
/**
105+
* [description]
106+
*
107+
* @property {Phaser.Input.Gamepad.GamepadManager} gamepad
108+
* @since 3.0.0
109+
*/
36110
this.gamepad = new Gamepad(this);
37111

112+
/**
113+
* [description]
114+
*
115+
* @property {[type]} activePointer
116+
* @since 3.0.0
117+
*/
38118
this.activePointer = new Pointer(this, 0);
39119

120+
/**
121+
* [description]
122+
*
123+
* @property {object} scale
124+
* @since 3.0.0
125+
*/
40126
this.scale = { x: 1, y: 1 };
41127

42-
// If the top-most Scene in the Scene List receives an input it will stop input from
43-
// propagating any lower down the scene list, i.e. if you have a UI Scene at the top
44-
// and click something on it, that click will not then be passed down to any other
45-
// Scene below. Disable this to have input events passed through all Scenes, all the time.
128+
/**
129+
* If the top-most Scene in the Scene List receives an input it will stop input from
130+
* propagating any lower down the scene list, i.e. if you have a UI Scene at the top
131+
* and click something on it, that click will not then be passed down to any other
132+
* Scene below. Disable this to have input events passed through all Scenes, all the time.
133+
*
134+
* @property {boolean} globalTopOnly
135+
* @default true
136+
* @since 3.0.0
137+
*/
46138
this.globalTopOnly = true;
47139

140+
/**
141+
* [description]
142+
*
143+
* @property {boolean} ignoreEvents
144+
* @default false
145+
* @since 3.0.0
146+
*/
48147
this.ignoreEvents = false;
49148

149+
/**
150+
* [description]
151+
*
152+
* @property {Phaser.Geom.Rectangle} bounds
153+
* @since 3.0.0
154+
*/
50155
this.bounds = new Rectangle();
51156

157+
/**
158+
* [description]
159+
*
160+
* @property {object} _tempPoint
161+
* @private
162+
* @since 3.0.0
163+
*/
52164
this._tempPoint = { x: 0, y: 0 };
165+
166+
/**
167+
* [description]
168+
*
169+
* @property {array} _tempHitTest
170+
* @private
171+
* @default []
172+
* @since 3.0.0
173+
*/
53174
this._tempHitTest = [];
54175

55176
game.events.once('boot', this.boot, this);
56177
},
57178

58179
/**
59-
* The Boot handler is called by Phaser.Game when it first starts up.
60-
* The renderer is available by now.
61-
*/
180+
* The Boot handler is called by Phaser.Game when it first starts up.
181+
* The renderer is available by now.
182+
*
183+
* @method Phaser.Input.InputManager#boot
184+
* @since 3.0.0
185+
*/
62186
boot: function ()
63187
{
64188
this.canvas = this.game.canvas;
@@ -71,6 +195,12 @@ var InputManager = new Class({
71195
this.gamepad.boot();
72196
},
73197

198+
/**
199+
* [description]
200+
*
201+
* @method Phaser.Input.InputManager#updateBounds
202+
* @since 3.0.0
203+
*/
74204
updateBounds: function ()
75205
{
76206
var clientRect = this.canvas.getBoundingClientRect();
@@ -82,6 +212,14 @@ var InputManager = new Class({
82212
bounds.height = clientRect.height;
83213
},
84214

215+
/**
216+
* [description]
217+
*
218+
* @method Phaser.Input.InputManager#update
219+
* @since 3.0.0
220+
*
221+
* @param {[type]} time - [description]
222+
*/
85223
update: function (time)
86224
{
87225
this.keyboard.update();
@@ -156,12 +294,23 @@ var InputManager = new Class({
156294
}
157295
},
158296

159-
// Will always return an array.
160-
// Array contains matching Interactive Objects.
161-
// Array will be empty if no objects were matched.
162-
163-
// x/y = pointer x/y (un-translated)
164-
297+
/**
298+
* Will always return an array.
299+
* Array contains matching Interactive Objects.
300+
* Array will be empty if no objects were matched.
301+
* x/y = pointer x/y (un-translated)
302+
*
303+
* @method Phaser.Input.InputManager#hitTest
304+
* @since 3.0.0
305+
*
306+
* @param {[type]} x - [description]
307+
* @param {[type]} y - [description]
308+
* @param {[type]} gameObjects - [description]
309+
* @param {[type]} camera - [description]
310+
* @param {[type]} output - [description]
311+
*
312+
* @return {[type]} [description]
313+
*/
165314
hitTest: function (x, y, gameObjects, camera, output)
166315
{
167316
if (output === undefined) { output = this._tempHitTest; }
@@ -207,9 +356,19 @@ var InputManager = new Class({
207356
return output;
208357
},
209358

210-
// x/y MUST be translated before being passed to this function,
211-
// unless the gameObject is guaranteed to not be rotated or scaled in any way
212-
359+
/**
360+
* x/y MUST be translated before being passed to this function,
361+
* unless the gameObject is guaranteed to not be rotated or scaled in any way.
362+
*
363+
* @method Phaser.Input.InputManager#pointWithinHitArea
364+
* @since 3.0.0
365+
*
366+
* @param {[type]} gameObject - [description]
367+
* @param {[type]} x - [description]
368+
* @param {[type]} y - [description]
369+
*
370+
* @return {boolean} [description]
371+
*/
213372
pointWithinHitArea: function (gameObject, x, y)
214373
{
215374
var input = gameObject.input;
@@ -231,9 +390,19 @@ var InputManager = new Class({
231390
}
232391
},
233392

234-
// x/y MUST be translated before being passed to this function, unless the gameObject is guaranteed to
235-
// be not rotated or scaled in any way
236-
393+
/**
394+
* x/y MUST be translated before being passed to this function,
395+
* unless the gameObject is guaranteed to not be rotated or scaled in any way.
396+
*
397+
* @method Phaser.Input.InputManager#pointWithinInteractiveObject
398+
* @since 3.0.0
399+
*
400+
* @param {[type]} object - [description]
401+
* @param {[type]} x - [description]
402+
* @param {[type]} y - [description]
403+
*
404+
* @return {boolean} [description]
405+
*/
237406
pointWithinInteractiveObject: function (object, x, y)
238407
{
239408
if (!object.hitArea)
@@ -251,32 +420,83 @@ var InputManager = new Class({
251420
return object.hitAreaCallback(object.hitArea, x, y, object);
252421
},
253422

254-
// Called by Pointer class
423+
/**
424+
* [description]
425+
*
426+
* @method Phaser.Input.InputManager#transformX
427+
* @since 3.0.0
428+
*
429+
* @param {[type]} pageX - [description]
430+
*
431+
* @return {number} [description]
432+
*/
255433
transformX: function (pageX)
256434
{
257435
return (pageX - this.bounds.left) * this.scale.x;
258436
},
259437

438+
/**
439+
* [description]
440+
*
441+
* @method Phaser.Input.InputManager#transformY
442+
* @since 3.0.0
443+
*
444+
* @param {[type]} pageY - [description]
445+
*
446+
* @return {number} [description]
447+
*/
260448
transformY: function (pageY)
261449
{
262450
return (pageY - this.bounds.top) * this.scale.y;
263451
},
264452

453+
/**
454+
* [description]
455+
*
456+
* @method Phaser.Input.InputManager#getOffsetX
457+
* @since 3.0.0
458+
*
459+
* @return {number} [description]
460+
*/
265461
getOffsetX: function ()
266462
{
267463
return this.bounds.left;
268464
},
269465

466+
/**
467+
* [description]
468+
*
469+
* @method Phaser.Input.InputManager#getOffsetY
470+
* @since 3.0.0
471+
*
472+
* @return {number} [description]
473+
*/
270474
getOffsetY: function ()
271475
{
272476
return this.bounds.top;
273477
},
274478

479+
/**
480+
* [description]
481+
*
482+
* @method Phaser.Input.InputManager#getScaleX
483+
* @since 3.0.0
484+
*
485+
* @return {number} [description]
486+
*/
275487
getScaleX: function ()
276488
{
277489
return this.game.config.width / this.bounds.width;
278490
},
279491

492+
/**
493+
* [description]
494+
*
495+
* @method Phaser.Input.InputManager#getScaleY
496+
* @since 3.0.0
497+
*
498+
* @return {number} [description]
499+
*/
280500
getScaleY: function ()
281501
{
282502
return this.game.config.height / this.bounds.height;

0 commit comments

Comments
 (0)