Skip to content

Commit 6571511

Browse files
authored
Merge pull request phaserjs#4311 from jestarray/master
Updated tilemap jsdocs
2 parents 618c703 + ade92db commit 6571511

3 files changed

Lines changed: 53 additions & 26 deletions

File tree

src/tilemaps/Tilemap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,8 @@ var Tilemap = new Class({
717717
*
718718
* @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled.
719719
* @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object.
720-
* @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0.
721-
* @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0.
720+
* @param {number} [x=0] - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0.
721+
* @param {number} [y=0] - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0.
722722
*
723723
* @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed.
724724
*/

src/tilemaps/mapdata/LayerData.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var LayerData = new Class({
2929
if (config === undefined) { config = {}; }
3030

3131
/**
32-
* [description]
32+
* The name of the layer, if specified in Tiled.
3333
*
3434
* @name Phaser.Tilemaps.LayerData#name
3535
* @type {string}
@@ -38,7 +38,7 @@ var LayerData = new Class({
3838
this.name = GetFastValue(config, 'name', 'layer');
3939

4040
/**
41-
* [description]
41+
* The x offset of where to draw from the top left
4242
*
4343
* @name Phaser.Tilemaps.LayerData#x
4444
* @type {number}
@@ -47,7 +47,7 @@ var LayerData = new Class({
4747
this.x = GetFastValue(config, 'x', 0);
4848

4949
/**
50-
* [description]
50+
* The y offset of where to draw from the top left
5151
*
5252
* @name Phaser.Tilemaps.LayerData#y
5353
* @type {number}
@@ -56,7 +56,7 @@ var LayerData = new Class({
5656
this.y = GetFastValue(config, 'y', 0);
5757

5858
/**
59-
* [description]
59+
* The width in tile of the layer.
6060
*
6161
* @name Phaser.Tilemaps.LayerData#width
6262
* @type {number}
@@ -65,7 +65,7 @@ var LayerData = new Class({
6565
this.width = GetFastValue(config, 'width', 0);
6666

6767
/**
68-
* [description]
68+
* The height in tiles of the layer.
6969
*
7070
* @name Phaser.Tilemaps.LayerData#height
7171
* @type {number}
@@ -74,7 +74,7 @@ var LayerData = new Class({
7474
this.height = GetFastValue(config, 'height', 0);
7575

7676
/**
77-
* [description]
77+
* The pixel width of the tiles.
7878
*
7979
* @name Phaser.Tilemaps.LayerData#tileWidth
8080
* @type {number}
@@ -83,7 +83,7 @@ var LayerData = new Class({
8383
this.tileWidth = GetFastValue(config, 'tileWidth', 0);
8484

8585
/**
86-
* [description]
86+
* The pixel height of the tiles.
8787
*
8888
* @name Phaser.Tilemaps.LayerData#tileHeight
8989
* @type {number}
@@ -110,7 +110,7 @@ var LayerData = new Class({
110110
this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight);
111111

112112
/**
113-
* [description]
113+
* The width in pixels of the entire layer.
114114
*
115115
* @name Phaser.Tilemaps.LayerData#widthInPixels
116116
* @type {number}
@@ -119,7 +119,7 @@ var LayerData = new Class({
119119
this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth);
120120

121121
/**
122-
* [description]
122+
* The height in pixels of the entire layer.
123123
*
124124
* @name Phaser.Tilemaps.LayerData#heightInPixels
125125
* @type {number}
@@ -146,7 +146,7 @@ var LayerData = new Class({
146146
this.visible = GetFastValue(config, 'visible', true);
147147

148148
/**
149-
* [description]
149+
* Layer specific properties (can be specified in Tiled)
150150
*
151151
* @name Phaser.Tilemaps.LayerData#properties
152152
* @type {object}
@@ -191,10 +191,10 @@ var LayerData = new Class({
191191
this.bodies = GetFastValue(config, 'bodies', []);
192192

193193
/**
194-
* [description]
194+
* An array of the tile indexes
195195
*
196196
* @name Phaser.Tilemaps.LayerData#data
197-
* @type {array}
197+
* @type {(number[])}
198198
* @since 3.0.0
199199
*/
200200
this.data = GetFastValue(config, 'data', []);

src/tilemaps/mapdata/MapData.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@
66

77
var Class = require('../../utils/Class');
88
var GetFastValue = require('../../utils/object/GetFastValue');
9+
var LayerData = require('./LayerData');
10+
var ObjectLayer = require("./ObjectLayer");
11+
var Tileset = require('../Tileset');
12+
13+
/**
14+
* @typedef {object} MapDataConfig
15+
* @property {string} [name] - The key in the Phaser cache that corresponds to the loaded tilemap data.
16+
* @property {number} [width=0] - The width of the entire tilemap.
17+
* @property {number} [height=0] - The height of the entire tilemap.
18+
* @property {number} [tileWidth=0] - The width of the tiles.
19+
* @property {number} [tileHeight=0] - The height of the tiles.
20+
* @property {number} [widthInPixels] - The width in pixels of the entire tilemap.
21+
* @property {number} [heightInPixels] - The height in pixels of the entire tilemap.
22+
* @property {number} [widthInPixels=0] - The pixel size of the entire tilemap.
23+
* @property {integer} [format] - [description]
24+
* @property {string} [orientation] - The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'.
25+
* @property {string} [renderOrder] - Determines the draw order of tilemap. Default is right-down.
26+
* @property {number} [version] - The version of Tiled the map uses.
27+
* @property {number} [properties] - Map specific properties (can be specified in Tiled).
28+
* @property {LayerData[]} [layers] - The layers of the tilemap.
29+
* @property {array} [images] - An array with all the layers configured to the MapData.
30+
* @property {object} [objects] - An array of Tiled Image Layers.
31+
* @property {object} [collision] - An object of Tiled Object Layers.
32+
* @property {Tileset[]} [tilesets] - The tilesets the map uses.
33+
* @property {array} [imageCollections] - The collection of images the map uses(specified in Tiled).
34+
* @property {array} [tiles] - [description]
35+
*/
936

1037
/**
1138
* @classdesc
@@ -18,7 +45,7 @@ var GetFastValue = require('../../utils/object/GetFastValue');
1845
* @constructor
1946
* @since 3.0.0
2047
*
21-
* @param {object} [config] - [description]
48+
* @param {MapDataConfig} [config] - [description]
2249
*/
2350
var MapData = new Class({
2451

@@ -29,7 +56,7 @@ var MapData = new Class({
2956
if (config === undefined) { config = {}; }
3057

3158
/**
32-
* [description]
59+
* The key in the Phaser cache that corresponds to the loaded tilemap data.
3360
*
3461
* @name Phaser.Tilemaps.MapData#name
3562
* @type {string}
@@ -38,7 +65,7 @@ var MapData = new Class({
3865
this.name = GetFastValue(config, 'name', 'map');
3966

4067
/**
41-
* [description]
68+
* The width of the entire tilemap.
4269
*
4370
* @name Phaser.Tilemaps.MapData#width
4471
* @type {number}
@@ -47,7 +74,7 @@ var MapData = new Class({
4774
this.width = GetFastValue(config, 'width', 0);
4875

4976
/**
50-
* [description]
77+
* The height of the entire tilemap.
5178
*
5279
* @name Phaser.Tilemaps.MapData#height
5380
* @type {number}
@@ -56,7 +83,7 @@ var MapData = new Class({
5683
this.height = GetFastValue(config, 'height', 0);
5784

5885
/**
59-
* [description]
86+
* The width of the tiles.
6087
*
6188
* @name Phaser.Tilemaps.MapData#tileWidth
6289
* @type {number}
@@ -65,7 +92,7 @@ var MapData = new Class({
6592
this.tileWidth = GetFastValue(config, 'tileWidth', 0);
6693

6794
/**
68-
* [description]
95+
* The height of the tiles.
6996
*
7097
* @name Phaser.Tilemaps.MapData#tileHeight
7198
* @type {number}
@@ -74,7 +101,7 @@ var MapData = new Class({
74101
this.tileHeight = GetFastValue(config, 'tileHeight', 0);
75102

76103
/**
77-
* [description]
104+
* The width in pixels of the entire tilemap.
78105
*
79106
* @name Phaser.Tilemaps.MapData#widthInPixels
80107
* @type {number}
@@ -83,7 +110,7 @@ var MapData = new Class({
83110
this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.tileWidth);
84111

85112
/**
86-
* [description]
113+
* The height in pixels of the entire tilemap.
87114
*
88115
* @name Phaser.Tilemaps.MapData#heightInPixels
89116
* @type {number}
@@ -145,7 +172,7 @@ var MapData = new Class({
145172
* An array with all the layers configured to the MapData.
146173
*
147174
* @name Phaser.Tilemaps.MapData#layers
148-
* @type {array}
175+
* @type {(LayerData[]|ObjectLayer)}
149176
* @since 3.0.0
150177
*/
151178
this.layers = GetFastValue(config, 'layers', []);
@@ -169,7 +196,7 @@ var MapData = new Class({
169196
this.objects = GetFastValue(config, 'objects', {});
170197

171198
/**
172-
* An object of collision data. Must be created as physics object or will return undefined.
199+
* An object of collision data. Must be created as physics object or will return undefined.
173200
*
174201
* @name Phaser.Tilemaps.MapData#collision
175202
* @type {object}
@@ -181,13 +208,13 @@ var MapData = new Class({
181208
* An array of Tilesets.
182209
*
183210
* @name Phaser.Tilemaps.MapData#tilesets
184-
* @type {array}
211+
* @type {Tileset[]}
185212
* @since 3.0.0
186213
*/
187214
this.tilesets = GetFastValue(config, 'tilesets', []);
188215

189216
/**
190-
* [description]
217+
* The collection of images the map uses(specified in Tiled)
191218
*
192219
* @name Phaser.Tilemaps.MapData#imageCollections
193220
* @type {array}

0 commit comments

Comments
 (0)