Skip to content

Commit 41d7c4b

Browse files
committed
Add callbacks on Input and Geom
1 parent f30218d commit 41d7c4b

6 files changed

Lines changed: 74 additions & 13 deletions

File tree

src/actions/SetHitArea.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
*
1010
* @function Phaser.Actions.SetHitArea
1111
* @since 3.0.0
12-
*
12+
*
1313
* @param {array} items - An array of Game Objects. The contents of this array are updated by this Action.
1414
* @param {any} hitArea - [description]
15-
* @param {function} hitAreaCallback - [description]
15+
* @param {HitAreaCallback} hitAreaCallback - [description]
1616
*
1717
* @return {array} The array of Game Objects that was passed to this Action.
1818
*/

src/geom/triangle/CenterOn.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
var Centroid = require('./Centroid');
88
var Offset = require('./Offset');
99

10+
/**
11+
* @callback CenterFunction
12+
*
13+
* @param {Phaser.Geom.Triangle} triangle - [description]
14+
*
15+
* @return {Phaser.Math.Vector2} [description]
16+
*/
17+
1018
/**
1119
* [description]
1220
*
@@ -16,7 +24,7 @@ var Offset = require('./Offset');
1624
* @param {Phaser.Geom.Triangle} triangle - [description]
1725
* @param {number} x - [description]
1826
* @param {number} y - [description]
19-
* @param {function} [centerFunc] - [description]
27+
* @param {CenterFunction} [centerFunc] - [description]
2028
*
2129
* @return {Phaser.Geom.Triangle} [description]
2230
*/

src/input/InputPlugin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ var InputPlugin = new Class({
402402
*
403403
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
404404
* @param {object} shape - [description]
405-
* @param {function} callback - [description]
405+
* @param {HitAreaCallback} callback - [description]
406406
* @param {boolean} [dropZone=false] - [description]
407407
*
408408
* @return {Phaser.Input.InputPlugin} This Input Plugin.
@@ -1053,7 +1053,7 @@ var InputPlugin = new Class({
10531053
*
10541054
* @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to set the hit area on.
10551055
* @param {object} [shape] - The shape or object to check if the pointer is within for hit area checks.
1056-
* @param {function} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
1056+
* @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
10571057
*
10581058
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
10591059
*/
@@ -1091,7 +1091,7 @@ var InputPlugin = new Class({
10911091
* @param {number} x - The center of the circle.
10921092
* @param {number} y - The center of the circle.
10931093
* @param {number} radius - The radius of the circle.
1094-
* @param {function} [callback] - The hit area callback. If undefined it uses Circle.Contains.
1094+
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains.
10951095
*
10961096
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
10971097
*/
@@ -1115,7 +1115,7 @@ var InputPlugin = new Class({
11151115
* @param {number} y - The center of the ellipse.
11161116
* @param {number} width - The width of the ellipse.
11171117
* @param {number} height - The height of the ellipse.
1118-
* @param {function} [callback] - The hit area callback. If undefined it uses Ellipse.Contains.
1118+
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains.
11191119
*
11201120
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
11211121
*/
@@ -1135,7 +1135,7 @@ var InputPlugin = new Class({
11351135
* @since 3.0.0
11361136
*
11371137
* @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to set as having an ellipse hit area.
1138-
* @param {function} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
1138+
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
11391139
*
11401140
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
11411141
*/
@@ -1189,7 +1189,7 @@ var InputPlugin = new Class({
11891189
* @param {number} y - The top-left of the rectangle.
11901190
* @param {number} width - The width of the rectangle.
11911191
* @param {number} height - The height of the rectangle.
1192-
* @param {function} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
1192+
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
11931193
*
11941194
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
11951195
*/
@@ -1215,7 +1215,7 @@ var InputPlugin = new Class({
12151215
* @param {number} y2 - The y coordinate of the second point of the triangle.
12161216
* @param {number} x3 - The x coordinate of the third point of the triangle.
12171217
* @param {number} y3 - The y coordinate of the third point of the triangle.
1218-
* @param {function} [callback] - The hit area callback. If undefined it uses Triangle.Contains.
1218+
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains.
12191219
*
12201220
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
12211221
*/

src/input/InteractiveObject.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,47 @@
66

77
// Phaser.Input.InteractiveObject
88

9+
/**
10+
* @callback HitAreaCallback
11+
*
12+
* @param {any} hitArea - [description]
13+
* @param {number} x - [description]
14+
* @param {number} y - [description]
15+
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
16+
*/
17+
18+
/**
19+
* @typedef {object} InteractiveObject
20+
*
21+
* @property {Phaser.GameObjects.GameObject} gameObject - [description]
22+
* @property {boolean} enabled - [description]
23+
* @property {boolean} draggable - [description]
24+
* @property {boolean} dropZone - [description]
25+
* @property {[type]} target - [description]
26+
* @property {Phaser.Cameras.Scene2D.Camera} camera - [description]
27+
* @property {any} hitArea - [description]
28+
* @property {HitAreaCallback} hitAreaCallback - [description]
29+
* @property {number} localX - [description]
30+
* @property {number} localY - [description]
31+
* @property {(0|1|2)} dragState - [description]
32+
* @property {number} dragStartX - [description]
33+
* @property {number} dragStartY - [description]
34+
* @property {number} dragX - [description]
35+
* @property {number} dragY - [description]
36+
*/
37+
38+
/**
39+
* [description]
40+
*
41+
* @method Phaser.Input.Pointer#positionToCamera
42+
* @since 3.0.0
43+
*
44+
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
45+
* @param {any} hitArea - [description]
46+
* @param {HitAreaCallback} hitAreaCallback - [description]
47+
*
48+
* @return {InteractiveObject} [description]
49+
*/
950
var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
1051
{
1152
return {

src/input/keyboard/combo/KeyCombo.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ var GetFastValue = require('../../../utils/object/GetFastValue');
99
var ProcessKeyCombo = require('./ProcessKeyCombo');
1010
var ResetKeyCombo = require('./ResetKeyCombo');
1111

12+
/**
13+
* @callback KeyboardKeydownCallback
14+
*
15+
* @param {KeyboardEvent} event - [description]
16+
*/
17+
1218
/**
1319
* @classdesc
1420
* [description]
@@ -219,7 +225,7 @@ var KeyCombo = new Class({
219225
* [description]
220226
*
221227
* @name Phaser.Input.Keyboard.KeyCombo#onKeyDown
222-
* @type {function}
228+
* @type {KeyboardKeydownCallback}
223229
* @since 3.0.0
224230
*/
225231
this.onKeyDown = onKeyDownHandler;

src/input/touch/TouchManager.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ var Class = require('../../utils/Class');
1010
// https://patrickhlauke.github.io/touch/tests/results/
1111
// https://www.html5rocks.com/en/mobile/touch/
1212

13+
/**
14+
* @callback TouchHandler
15+
*
16+
* @param {TouchEvent} event - [description]
17+
*/
18+
1319
/**
1420
* @classdesc
1521
* [description]
@@ -69,7 +75,7 @@ var TouchManager = new Class({
6975
* [description]
7076
*
7177
* @name Phaser.Input.Touch.TouchManager#handler
72-
* @type {function}
78+
* @type {TouchHandler}
7379
* @since 3.0.0
7480
*/
7581
this.handler;
@@ -154,7 +160,7 @@ var TouchManager = new Class({
154160
target.addEventListener('touchmove', handler, passive);
155161
target.addEventListener('touchend', handler, passive);
156162
}
157-
163+
158164
this.handler = handler;
159165
},
160166

0 commit comments

Comments
 (0)