Skip to content

Commit 3938675

Browse files
committed
Input typedefs
1 parent c9bdb83 commit 3938675

34 files changed

Lines changed: 153 additions & 124 deletions

src/actions/SetHitArea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action.
1818
* @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
19-
* @param {HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
19+
* @param {Phaser.Input.Types.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
2020
*
2121
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
2222
*/

src/gameobjects/GameObject.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ var GameObject = new Class({
159159
* Not usually set directly. Instead call `GameObject.setInteractive()`.
160160
*
161161
* @name Phaser.GameObjects.GameObject#input
162-
* @type {?Phaser.Input.InteractiveObject}
162+
* @type {?Phaser.Input.Types.InteractiveObject}
163163
* @default null
164164
* @since 3.0.0
165165
*/
@@ -386,8 +386,8 @@ var GameObject = new Class({
386386
* @method Phaser.GameObjects.GameObject#setInteractive
387387
* @since 3.0.0
388388
*
389-
* @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
390-
* @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
389+
* @param {(Phaser.Input.Types.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
390+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
391391
* @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target?
392392
*
393393
* @return {this} This GameObject.

src/gameobjects/group/typedefs/GroupCreateConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* @property {?number} [setAlpha.value=0] - The alpha value of each new Game Object.
4141
* @property {?number} [setAlpha.step=0] - Increment each Game Object's alpha from the previous by this amount, starting from `setAlpha.value`.
4242
* @property {?*} [hitArea] - A geometric shape that defines the hit area for the Game Object.
43-
* @property {?HitAreaCallback} [hitAreaCallback] - A callback to be invoked when the Game Object is interacted with.
43+
* @property {?Phaser.Input.Types.HitAreaCallback} [hitAreaCallback] - A callback to be invoked when the Game Object is interacted with.
4444
* @property {?(false|Phaser.Actions.Types.GridAlignConfig)} [gridAlign=false] - Align the new Game Objects in a grid using these settings.
4545
*
4646
* @see Phaser.Actions.GridAlign

src/gameobjects/zone/Zone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ var Zone = new Class({
236236
* @since 3.0.0
237237
*
238238
* @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape.
239-
* @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape.
239+
* @param {Phaser.Input.Types.HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape.
240240
*
241241
* @return {Phaser.GameObjects.Zone} This Game Object.
242242
*/

src/input/CreateInteractiveObject.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,6 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7-
/**
8-
* @callback HitAreaCallback
9-
*
10-
* @param {any} hitArea - The hit area object.
11-
* @param {number} x - The translated x coordinate of the hit test event.
12-
* @param {number} y - The translated y coordinate of the hit test event.
13-
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that invoked the hit test.
14-
*
15-
* @return {boolean} `true` if the coordinates fall within the space of the hitArea, otherwise `false`.
16-
*/
17-
18-
/**
19-
* @typedef {object} Phaser.Input.InteractiveObject
20-
*
21-
* @property {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound.
22-
* @property {boolean} enabled - Is this Interactive Object currently enabled for input events?
23-
* @property {boolean} draggable - Is this Interactive Object draggable? Enable with `InputPlugin.setDraggable`.
24-
* @property {boolean} dropZone - Is this Interactive Object a drag-targets drop zone? Set when the object is created.
25-
* @property {(boolean|string)} cursor - Should this Interactive Object change the cursor (via css) when over? (desktop only)
26-
* @property {?Phaser.GameObjects.GameObject} target - An optional drop target for a draggable Interactive Object.
27-
* @property {Phaser.Cameras.Scene2D.Camera} camera - The most recent Camera to be tested against this Interactive Object.
28-
* @property {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle.
29-
* @property {HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests.
30-
* @property {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
31-
* @property {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
32-
* @property {(0|1|2)} dragState - The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged.
33-
* @property {number} dragStartX - The x coordinate that the Pointer started dragging this Interactive Object from.
34-
* @property {number} dragStartY - The y coordinate that the Pointer started dragging this Interactive Object from.
35-
* @property {number} dragX - The x coordinate that this Interactive Object is currently being dragged to.
36-
* @property {number} dragY - The y coordinate that this Interactive Object is currently being dragged to.
37-
*/
38-
397
/**
408
* Creates a new Interactive Object.
419
*
@@ -48,9 +16,9 @@
4816
*
4917
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound.
5018
* @param {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle.
51-
* @param {HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests.
19+
* @param {Phaser.Input.Types.HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests.
5220
*
53-
* @return {Phaser.Input.InteractiveObject} The new Interactive Object.
21+
* @return {Phaser.Input.Types.InteractiveObject} The new Interactive Object.
5422
*/
5523
var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback)
5624
{

src/input/InputManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ var InputManager = new Class({
690690
* @private
691691
* @since 3.10.0
692692
*
693-
* @param {Phaser.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method.
693+
* @param {Phaser.Input.Types.InteractiveObject} interactiveObject - The Interactive Object that called this method.
694694
*/
695695
setCursor: function (interactiveObject)
696696
{
@@ -710,7 +710,7 @@ var InputManager = new Class({
710710
* @private
711711
* @since 3.10.0
712712
*
713-
* @param {Phaser.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method.
713+
* @param {Phaser.Input.Types.InteractiveObject} interactiveObject - The Interactive Object that called this method.
714714
*/
715715
resetCursor: function (interactiveObject)
716716
{
@@ -1590,7 +1590,7 @@ var InputManager = new Class({
15901590
* @method Phaser.Input.InputManager#pointWithinInteractiveObject
15911591
* @since 3.0.0
15921592
*
1593-
* @param {Phaser.Input.InteractiveObject} object - The Interactive Object to check against.
1593+
* @param {Phaser.Input.Types.InteractiveObject} object - The Interactive Object to check against.
15941594
* @param {number} x - The translated x coordinate for the hit test.
15951595
* @param {number} y - The translated y coordinate for the hit test.
15961596
*

src/input/InputPlugin.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ var InputPlugin = new Class({
209209
* Internal event propagation callback container.
210210
*
211211
* @name Phaser.Input.InputPlugin#_eventContainer
212-
* @type {Phaser.Input.EventData}
212+
* @type {Phaser.Input.Types.EventData}
213213
* @private
214214
* @since 3.13.0
215215
*/
@@ -723,8 +723,8 @@ var InputPlugin = new Class({
723723
* @since 3.0.0
724724
*
725725
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to be enabled for input.
726-
* @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
727-
* @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
726+
* @param {(Phaser.Input.Types.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
727+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
728728
* @param {boolean} [dropZone=false] - Is this Game Object a drop zone or not?
729729
*
730730
* @return {Phaser.Input.InputPlugin} This Input Plugin.
@@ -1654,19 +1654,6 @@ var InputPlugin = new Class({
16541654
return CreatePixelPerfectHandler(textureManager, alphaTolerance);
16551655
},
16561656

1657-
/**
1658-
* @typedef {object} Phaser.Input.InputConfiguration
1659-
*
1660-
* @property {any} [hitArea] - The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame.
1661-
* @property {function} [hitAreaCallback] - The callback that determines if the pointer is within the Hit Area shape or not.
1662-
* @property {boolean} [draggable=false] - If `true` the Interactive Object will be set to be draggable and emit drag events.
1663-
* @property {boolean} [dropZone=false] - If `true` the Interactive Object will be set to be a drop zone for draggable objects.
1664-
* @property {boolean} [useHandCursor=false] - If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`.
1665-
* @property {string} [cursor] - The CSS string to be used when the cursor is over this Interactive Object.
1666-
* @property {boolean} [pixelPerfect=false] - If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects.
1667-
* @property {integer} [alphaTolerance=1] - If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback.
1668-
*/
1669-
16701657
/**
16711658
* Sets the hit area for the given array of Game Objects.
16721659
*
@@ -1684,8 +1671,8 @@ var InputPlugin = new Class({
16841671
* @since 3.0.0
16851672
*
16861673
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on.
1687-
* @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
1688-
* @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
1674+
* @param {(Phaser.Input.Types.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
1675+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
16891676
*
16901677
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
16911678
*/
@@ -1772,7 +1759,7 @@ var InputPlugin = new Class({
17721759
* @param {number} x - The center of the circle.
17731760
* @param {number} y - The center of the circle.
17741761
* @param {number} radius - The radius of the circle.
1775-
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains.
1762+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains.
17761763
*
17771764
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
17781765
*/
@@ -1797,7 +1784,7 @@ var InputPlugin = new Class({
17971784
* @param {number} y - The center of the ellipse.
17981785
* @param {number} width - The width of the ellipse.
17991786
* @param {number} height - The height of the ellipse.
1800-
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains.
1787+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains.
18011788
*
18021789
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
18031790
*/
@@ -1818,7 +1805,7 @@ var InputPlugin = new Class({
18181805
* @since 3.0.0
18191806
*
18201807
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area.
1821-
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
1808+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
18221809
*
18231810
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
18241811
*/
@@ -1880,7 +1867,7 @@ var InputPlugin = new Class({
18801867
* @param {number} y - The top-left of the rectangle.
18811868
* @param {number} width - The width of the rectangle.
18821869
* @param {number} height - The height of the rectangle.
1883-
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
1870+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
18841871
*
18851872
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
18861873
*/
@@ -1907,7 +1894,7 @@ var InputPlugin = new Class({
19071894
* @param {number} y2 - The y coordinate of the second point of the triangle.
19081895
* @param {number} x3 - The x coordinate of the third point of the triangle.
19091896
* @param {number} y3 - The y coordinate of the third point of the triangle.
1910-
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains.
1897+
* @param {Phaser.Input.Types.HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains.
19111898
*
19121899
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
19131900
*/

src/input/InputPluginCache.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ var GetValue = require('../utils/object/GetValue');
1010
// These are the source objects, not instantiated.
1111
var inputPlugins = {};
1212

13-
/**
14-
* @typedef {object} InputPluginContainer
15-
*
16-
* @property {string} key - The unique name of this plugin in the input plugin cache.
17-
* @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated.
18-
* @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used.
19-
*/
20-
2113
/**
2214
* @namespace Phaser.Input.InputPluginCache
2315
*/
@@ -56,7 +48,7 @@ InputPluginCache.register = function (key, plugin, mapping, settingsKey, configK
5648
*
5749
* @param {string} key - The key of the input plugin to get.
5850
*
59-
* @return {InputPluginContainer} The input plugin object.
51+
* @return {Phaser.Input.Types.InputPluginContainer} The input plugin object.
6052
*/
6153
InputPluginCache.getPlugin = function (key)
6254
{

src/input/events/GAMEOBJECT_DOWN_EVENT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
*
3131
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
3232
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was pressed down on.
33-
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
33+
* @param {Phaser.Input.Types.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
3434
*/
3535
module.exports = 'gameobjectdown';

src/input/events/GAMEOBJECT_MOVE_EVENT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
*
3131
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
3232
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was moved on.
33-
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
33+
* @param {Phaser.Input.Types.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
3434
*/
3535
module.exports = 'gameobjectmove';

0 commit comments

Comments
 (0)