Skip to content

Commit 30f410d

Browse files
committed
Fix types in Tilemaps
1 parent b6f2c80 commit 30f410d

12 files changed

Lines changed: 464 additions & 426 deletions

File tree

src/tilemaps/Tile.js

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

src/tilemaps/Tilemap.js

Lines changed: 156 additions & 136 deletions
Large diffs are not rendered by default.

src/tilemaps/Tileset.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var Tileset = new Class({
4242

4343
/**
4444
* The name of the Tileset.
45-
*
45+
*
4646
* @name Phaser.Tilemaps.Tileset#name
4747
* @type {string}
4848
* @since 3.0.0
@@ -51,7 +51,7 @@ var Tileset = new Class({
5151

5252
/**
5353
* The starting index of the first tile index this Tileset contains.
54-
*
54+
*
5555
* @name Phaser.Tilemaps.Tileset#firstgid
5656
* @type {integer}
5757
* @since 3.0.0
@@ -60,7 +60,7 @@ var Tileset = new Class({
6060

6161
/**
6262
* The width of each tile (in pixels). Use setTileSize to change.
63-
*
63+
*
6464
* @name Phaser.Tilemaps.Tileset#tileWidth
6565
* @type {integer}
6666
* @readOnly
@@ -70,7 +70,7 @@ var Tileset = new Class({
7070

7171
/**
7272
* The height of each tile (in pixels). Use setTileSize to change.
73-
*
73+
*
7474
* @name Phaser.Tilemaps.Tileset#tileHeight
7575
* @type {integer}
7676
* @readOnly
@@ -80,7 +80,7 @@ var Tileset = new Class({
8080

8181
/**
8282
* The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change.
83-
*
83+
*
8484
* @name Phaser.Tilemaps.Tileset#tileMargin
8585
* @type {integer}
8686
* @readOnly
@@ -90,7 +90,7 @@ var Tileset = new Class({
9090

9191
/**
9292
* The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change.
93-
*
93+
*
9494
* @name Phaser.Tilemaps.Tileset#tileSpacing
9595
* @type {integer}
9696
* @readOnly
@@ -101,7 +101,7 @@ var Tileset = new Class({
101101
/**
102102
* Tileset-specific properties per tile that are typically defined in the Tiled editor in the
103103
* Tileset editor.
104-
*
104+
*
105105
* @name Phaser.Tilemaps.Tileset#tileProperties
106106
* @type {object}
107107
* @since 3.0.0
@@ -111,7 +111,7 @@ var Tileset = new Class({
111111
/**
112112
* Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within
113113
* the Tileset collision editor. This is where collision objects and terrain are stored.
114-
*
114+
*
115115
* @name Phaser.Tilemaps.Tileset#tileData
116116
* @type {object}
117117
* @since 3.0.0
@@ -120,17 +120,17 @@ var Tileset = new Class({
120120

121121
/**
122122
* The cached image that contains the individual tiles. Use setImage to set.
123-
*
123+
*
124124
* @name Phaser.Tilemaps.Tileset#image
125-
* @type {Phaser.Textures.Texture|null}
125+
* @type {?Phaser.Textures.Texture}
126126
* @readOnly
127127
* @since 3.0.0
128128
*/
129129
this.image = null;
130130

131131
/**
132132
* The number of tile rows in the the tileset.
133-
*
133+
*
134134
* @name Phaser.Tilemaps.Tileset#rows
135135
* @type {integer}
136136
* @readOnly
@@ -140,7 +140,7 @@ var Tileset = new Class({
140140

141141
/**
142142
* The number of tile columns in the tileset.
143-
*
143+
*
144144
* @name Phaser.Tilemaps.Tileset#columns
145145
* @type {integer}
146146
* @readOnly
@@ -150,7 +150,7 @@ var Tileset = new Class({
150150

151151
/**
152152
* The total number of tiles in the tileset.
153-
*
153+
*
154154
* @name Phaser.Tilemaps.Tileset#total
155155
* @type {integer}
156156
* @readOnly
@@ -161,7 +161,7 @@ var Tileset = new Class({
161161
/**
162162
* The look-up table to specific tile image texture coordinates (UV in pixels). Each element
163163
* contains the coordinates for a tile in an object of the form {x, y}.
164-
*
164+
*
165165
* @name Phaser.Tilemaps.Tileset#texCoordinates
166166
* @type {object[]}
167167
* @readOnly
@@ -178,8 +178,8 @@ var Tileset = new Class({
178178
* @since 3.0.0
179179
*
180180
* @param {integer} tileIndex - The unique id of the tile across all tilesets in the map.
181-
*
182-
* @return {object|undefined|null}
181+
*
182+
* @return {?(object|undefined)}
183183
*/
184184
getTileProperties: function (tileIndex)
185185
{
@@ -197,8 +197,8 @@ var Tileset = new Class({
197197
* @since 3.0.0
198198
*
199199
* @param {integer} tileIndex - The unique id of the tile across all tilesets in the map.
200-
*
201-
* @return {object|undefined|null}
200+
*
201+
* @return {?object|undefined}
202202
*/
203203
getTileData: function (tileIndex)
204204
{
@@ -215,8 +215,8 @@ var Tileset = new Class({
215215
* @since 3.0.0
216216
*
217217
* @param {integer} tileIndex - The unique id of the tile across all tilesets in the map.
218-
*
219-
* @return {object|null}
218+
*
219+
* @return {?object}
220220
*/
221221
getTileCollisionGroup: function (tileIndex)
222222
{
@@ -232,7 +232,7 @@ var Tileset = new Class({
232232
* @since 3.0.0
233233
*
234234
* @param {integer} tileIndex - The unique id of the tile across all tilesets in the map.
235-
*
235+
*
236236
* @return {boolean}
237237
*/
238238
containsTileIndex: function (tileIndex)
@@ -251,8 +251,8 @@ var Tileset = new Class({
251251
* @since 3.0.0
252252
*
253253
* @param {integer} tileIndex - The unique id of the tile across all tilesets in the map.
254-
*
255-
* @return {object|null} Object in the form { x, y } representing the top-left UV coordinate
254+
*
255+
* @return {?object} Object in the form { x, y } representing the top-left UV coordinate
256256
* within the Tileset image.
257257
*/
258258
getTileTextureCoordinates: function (tileIndex)
@@ -269,7 +269,7 @@ var Tileset = new Class({
269269
* @since 3.0.0
270270
*
271271
* @param {Phaser.Textures.Texture} texture - The image that contains the tiles.
272-
*
272+
*
273273
* @return {Phaser.Tilemaps.Tileset} This Tileset object.
274274
*/
275275
setImage: function (texture)
@@ -289,7 +289,7 @@ var Tileset = new Class({
289289
*
290290
* @param {integer} [tileWidth] - The width of a tile in pixels.
291291
* @param {integer} [tileHeight] - The height of a tile in pixels.
292-
*
292+
*
293293
* @return {Phaser.Tilemaps.Tileset} This Tileset object.
294294
*/
295295
setTileSize: function (tileWidth, tileHeight)
@@ -313,7 +313,7 @@ var Tileset = new Class({
313313
*
314314
* @param {integer} [margin] - The margin around the tiles in the sheet (in pixels).
315315
* @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels).
316-
*
316+
*
317317
* @return {Phaser.Tilemaps.Tileset} This Tileset object.
318318
*/
319319
setSpacing: function (margin, spacing)
@@ -337,7 +337,7 @@ var Tileset = new Class({
337337
*
338338
* @param {integer} imageWidth - The (expected) width of the image to slice.
339339
* @param {integer} imageHeight - The (expected) height of the image to slice.
340-
*
340+
*
341341
* @return {Phaser.Tilemaps.Tileset} This Tileset object.
342342
*/
343343
updateTileData: function (imageWidth, imageHeight)

src/tilemaps/components/FindByIndex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the
2020
* bottom-right. Otherwise it scans from the top-left.
2121
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
22-
*
23-
* @return {Phaser.Tilemaps.Tile|null} The first (or n skipped) tile with the matching index.
22+
*
23+
* @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index.
2424
*/
2525
var FindByIndex = function (findIndex, skip, reverse, layer)
2626
{

src/tilemaps/components/FindTile.js

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

77
var GetTilesWithin = require('./GetTilesWithin');
88

9+
/**
10+
* @callback FindTileCallback
11+
*
12+
* @param {Phaser.Tilemaps.Tile} value - [description]
13+
* @param {number} index - [description]
14+
* @param {Phaser.Tilemaps.Tile[]} array - [description]
15+
*
16+
* @return {boolean} [description]
17+
*/
18+
919
/**
1020
* Find the first tile in the given rectangular area (in tile coordinates) of the layer that
1121
* satisfies the provided testing function. I.e. finds the first tile for which `callback` returns
@@ -14,7 +24,7 @@ var GetTilesWithin = require('./GetTilesWithin');
1424
* @function Phaser.Tilemaps.Components.FindTile
1525
* @since 3.0.0
1626
*
17-
* @param {function} callback - The callback. Each tile in the given area will be passed to this
27+
* @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this
1828
* callback as the first and only parameter.
1929
* @param {object} [context] - The context under which the callback should be run.
2030
* @param {integer} [tileX=0] - [description]
@@ -29,8 +39,8 @@ var GetTilesWithin = require('./GetTilesWithin');
2939
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that
3040
* have at least one interesting face.
3141
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
32-
*
33-
* @return {Phaser.Tilemaps.Tile|null} A Tile that matches the search, or null if no Tile found
42+
*
43+
* @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found
3444
*/
3545
var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
3646
{

src/tilemaps/components/ForEachTile.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66

77
var GetTilesWithin = require('./GetTilesWithin');
88

9+
/**
10+
* @callback EachTileCallback
11+
*
12+
* @param {Phaser.Tilemaps.Tile} value - [description]
13+
* @param {number} index - [description]
14+
* @param {Phaser.Tilemaps.Tile[]} array - [description]
15+
*/
16+
917
/**
1018
* For each tile in the given rectangular area (in tile coordinates) of the layer, run the given
1119
* callback. Similar to Array.prototype.forEach in vanilla JS.
1220
*
1321
* @function Phaser.Tilemaps.Components.ForEachTile
1422
* @since 3.0.0
1523
*
16-
* @param {function} callback - The callback. Each tile in the given area will be passed to this
24+
* @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this
1725
* callback as the first and only parameter.
1826
* @param {object} [context] - The context under which the callback should be run.
1927
* @param {integer} [tileX=0] - [description]

src/tilemaps/components/RenderDebug.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ var Color = require('../../display/color');
1818
*
1919
* @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon.
2020
* @param {object} styleConfig - An object specifying the colors to use for the debug drawing.
21-
* @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at
21+
* @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at
2222
* non-colliding tile locations. If set to null, non-colliding tiles will not be drawn.
23-
* @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled
23+
* @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled
2424
* rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn.
25-
* @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting
25+
* @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting
2626
* tile faces. If set to null, interesting tile faces will not be drawn.
2727
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
2828
*/

0 commit comments

Comments
 (0)