Skip to content

Commit 75f13cf

Browse files
committed
TilemapLayer / Tileset documentation to Phaser conventions
- Reverted @member to @Property for uniformity - Expanded some comments
1 parent ce2acdd commit 75f13cf

2 files changed

Lines changed: 54 additions & 53 deletions

File tree

src/tilemap/TilemapLayer.js

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,73 +25,74 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
2525

2626
/**
2727
* A reference to the currently running Game.
28-
* @member {Phaser.Game}
28+
* @property {Phaser.Game} game
2929
* @protected
3030
* @readonly
3131
*/
3232
this.game = game;
3333

3434
/**
3535
* The Tilemap to which this layer is bound.
36-
* @member {Phaser.Tilemap}
36+
* @property {Phaser.Tilemap} map
3737
* @protected
3838
* @readonly
3939
*/
4040
this.map = tilemap;
4141

4242
/**
4343
* The layer object within the Tilemap that this layer represents.
44-
* @member {Phaser.TileLayer}
44+
* @property {Phaser.TileLayer} layer
4545
* @protected
4646
* @readonly
4747
*/
4848
this.layer = tilemap.layers[index];
4949

5050
/**
5151
* The canvas to which this TilemapLayer draws.
52-
* @member {HTMLCanvasElement}
52+
* @property {HTMLCanvasElement} canvas
5353
* @protected
5454
*/
5555
this.canvas = Phaser.Canvas.create(width, height, '', true);
5656

5757
/**
5858
* The 2d context of the canvas.
59-
* @member {CanvasRenderingContext2D}
59+
* @property {CanvasRenderingContext2D} context
6060
* @private
6161
*/
6262
this.context = this.canvas.getContext('2d');
6363

6464
/**
6565
* Required Pixi var.
66-
* @member {PIXI.BaseTexture}
66+
* @property {PIXI.BaseTexture} baseTexture
6767
* @protected
6868
*/
6969
this.baseTexture = new PIXI.BaseTexture(this.canvas);
7070

7171
/**
7272
* Required Pixi var.
73-
* @member {PIXI.Texture}
73+
* @property {PIXI.Texture} texture
7474
* @protected
7575
*/
7676
this.texture = new PIXI.Texture(this.baseTexture);
7777

7878
/**
7979
* Dimensions of the renderable area.
80-
* @member {Phaser.Frame}
80+
* @property {Phaser.Frame} textureFrame
81+
* @protected
8182
*/
8283
this.textureFrame = new Phaser.Frame(0, 0, 0, width, height, 'tilemapLayer', game.rnd.uuid());
8384

8485
Phaser.Image.call(this, this.game, 0, 0, this.texture, this.textureFrame);
8586

8687
/**
8788
* The name of the layer.
88-
* @member {string}
89+
* @property {string} name
8990
*/
9091
this.name = '';
9192

9293
/**
9394
* The const type of this object.
94-
* @member {number}
95+
* @property {number} type
9596
* @readonly
9697
* @protected
9798
* @default Phaser.TILEMAPLAYER
@@ -100,25 +101,22 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
100101

101102
/**
102103
* An object that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
103-
* @member {boolean}
104+
* @property {boolean} fixToCamera
104105
* @default
105106
*/
106107
this.fixedToCamera = true;
107108

108109
/**
109110
* If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
110-
* @member {Phaser.Point}
111+
* @property {Phaser.Point} cameraOffset
111112
*/
112113
this.cameraOffset = new Phaser.Point(0, 0);
113114

114115
/**
115116
* Settings that control standard (non-diagnostic) rendering.
116117
*
117-
* @member
118118
* @public
119-
*
120119
* @property {boolean} enableScrollDelta - When enabled, only new newly exposed areas of the layer are redraw after scrolling. This can greatly improve scrolling rendering performance, especially when there are many small tiles.
121-
*
122120
* @default
123121
*/
124122
this.renderSettings = {
@@ -131,17 +129,14 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
131129
/**
132130
* Enable an additional "debug rendering" pass to display collision information.
133131
*
134-
* @member {boolean}
132+
* @property {boolean} debug
135133
* @default
136134
*/
137135
this.debug = false;
138136

139137
/**
140138
* Settings used for debugging and diagnostics.
141139
*
142-
* @member
143-
* @public
144-
*
145140
* @property {?string} missingImageFill - A tile is rendered as a rectangle using the following fill if a valid tileset/image cannot be found. A value of `null` prevents additional rendering for tiles without a valid tileset image. _This takes effect even when debug rendering for the layer is not enabled._
146141
*
147142
* @property {?string} debuggedTileOverfill - If a Tile has `Tile#debug` true then, after normal tile image rendering, a rectangle with the following fill is drawn above/over it. _This takes effect even when debug rendering for the layer is not enabled._
@@ -171,45 +166,44 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
171166
/**
172167
* Speed at which this layer scrolls horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do).
173168
*
174-
* @member {number}
175-
* @public
176-
* @default 1
169+
* @property {number} scrollFactorX
170+
* @default
177171
*/
178172
this.scrollFactorX = 1;
179173

180174
/**
181175
* Speed at which this layer scrolls vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do)
182-
* @member {number}
176+
* @property {number} scrollFactorY
183177
* @public
184-
* @default 1
178+
* @default
185179
*/
186180
this.scrollFactorY = 1;
187181

188182
/**
189183
* If true tiles will be force rendered, even if such is not believed to be required.
190-
* @member {boolean} dirty
184+
* @property {boolean} dirty
191185
* @protected
192186
*/
193187
this.dirty = true;
194188

195189
/**
196190
* When ray-casting against tiles this is the number of steps it will jump. For larger tile sizes you can increase this to improve performance.
197-
* @member {integer}
191+
* @property {integer} rayStepRate
198192
* @default
199193
*/
200194
this.rayStepRate = 4;
201195

202196
/**
203197
* Flag controlling if the layer tiles wrap at the edges.
204-
* @member {boolean}
205-
* @default
198+
* @property {boolean} _wrap
206199
* @private
200+
* @default
207201
*/
208202
this._wrap = false;
209203

210204
/**
211205
* Local map data and calculation cache.
212-
* @member {object}
206+
* @property {object} _mc
213207
* @private
214208
*/
215209
this._mc = {
@@ -236,21 +230,21 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
236230

237231
/**
238232
* The current canvas left after scroll is applied.
239-
* @member {number}
233+
* @property {number} _scrollX
240234
* @private
241235
*/
242236
this._scrollX = 0;
243237

244238
/**
245239
* The current canvas top after scroll is applied.
246-
* @member {number}
240+
* @propety {number} _scrollY
247241
* @private
248242
*/
249243
this._scrollY = 0;
250244

251245
/**
252246
* Used for caching the tiles / array of tiles.
253-
* @member {Phaser.Tile[]}
247+
* @property {Phaser.Tile[]} _results
254248
* @private
255249
*/
256250
this._results = [];
@@ -263,7 +257,7 @@ Phaser.TilemapLayer.prototype.constructor = Phaser.TilemapLayer;
263257
/**
264258
* The index of this layer (`layer`) within the Tilemap.
265259
*
266-
* @member {integer} #index
260+
* @property {integer} index
267261
* @memberof Phaser.TilemapLayer
268262
* @readonly
269263
* @protected
@@ -281,7 +275,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, 'index', {
281275
*
282276
* Set to `null` to disable rendering anything for tiles without value tileset images.
283277
*
284-
* @member {?string} #tileColor
278+
* @property {?string} tileColor
285279
* @memberof Phaser.TilemapLayer
286280
* @default 'rgb(255, 255, 255)'
287281
* @deprecated Use `debugSettings.missingImageFill` instead.
@@ -574,7 +568,7 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
574568
/**
575569
* Flag controlling if the layer tiles wrap at the edges. Only works if the World size matches the Map size.
576570
*
577-
* @member {boolean} #wrap
571+
* @property {boolean} wrap
578572
* @memberof Phaser.TilemapLayer
579573
* @public
580574
* @default false
@@ -1082,7 +1076,7 @@ Phaser.TilemapLayer.prototype.renderDebug = function () {
10821076
/**
10831077
* Scrolls the map horizontally or returns the current x position.
10841078
*
1085-
* @member {number} #scrollX
1079+
* @property {number} scrollX
10861080
* @memberof Phaser.TilemapLayer
10871081
* @public
10881082
*/
@@ -1101,7 +1095,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollX", {
11011095
/**
11021096
* Scrolls the map vertically or returns the current y position.
11031097
*
1104-
* @member {number} #scrollY
1098+
* @property {number} scrollY
11051099
* @memberof Phaser.TilemapLayer
11061100
* @public
11071101
*/
@@ -1120,7 +1114,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollY", {
11201114
/**
11211115
* The width of the collision tiles (in pixels).
11221116
*
1123-
* @member {number} #collisionWidth
1117+
* @property {integer} collisionWidth
11241118
* @memberof Phaser.TilemapLayer
11251119
* @public
11261120
*/
@@ -1131,7 +1125,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionWidth", {
11311125
},
11321126

11331127
set: function (value) {
1134-
this._mc.cw = value;
1128+
this._mc.cw = value | 0;
11351129
this.dirty = true;
11361130
}
11371131

@@ -1140,7 +1134,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionWidth", {
11401134
/**
11411135
* The height of the collision tiles (in pixels).
11421136
*
1143-
* @member {number} #collisionHeight
1137+
* @property {integer} collisionHeight
11441138
* @memberof Phaser.TilemapLayer
11451139
* @public
11461140
*/
@@ -1151,7 +1145,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionHeight", {
11511145
},
11521146

11531147
set: function (value) {
1154-
this._mc.ch = value;
1148+
this._mc.ch = value | 0;
11551149
this.dirty = true;
11561150
}
11571151

src/tilemap/Tileset.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,73 +28,80 @@ Phaser.Tileset = function (name, firstgid, width, height, margin, spacing, prope
2828

2929
/**
3030
* The name of the Tileset.
31-
* @member {string}
31+
* @property {string} name
3232
*/
3333
this.name = name;
3434

3535
/**
3636
* The Tiled firstgid value.
3737
* This is the starting index of the first tile index this Tileset contains.
38-
* @member {integer}
38+
* @property {integer} firstgid
3939
*/
4040
this.firstgid = firstgid | 0;
4141

4242
/**
4343
* The width of each tile (in pixels).
44-
* @member {integer}
44+
* @property {integer} tileWidth
45+
* @readonly
4546
*/
4647
this.tileWidth = width | 0;
4748

4849
/**
4950
* The height of each tile (in pixels).
50-
* @member {integer}
51+
* @property {integer} tileHeight
52+
* @readonly
5153
*/
5254
this.tileHeight = height | 0;
5355

5456
/**
5557
* The margin around the tiles in the sheet (in pixels).
56-
* @member {integer}
58+
* Use `setSpacing` to change.
59+
* @property {integer} tileMarge
60+
* @readonly
5761
*/
62+
// Modified internally
5863
this.tileMargin = margin | 0;
5964

6065
/**
6166
* The spacing between each tile in the sheet (in pixels).
62-
* @member {integer}
67+
* Use `setSpacing` to change.
68+
* @property {integer} tileSpacing
6369
*/
6470
this.tileSpacing = spacing | 0;
6571

6672
/**
6773
* Tileset-specific properties that are typically defined in the Tiled editor.
68-
* @member {object}
74+
* @property {object} properties
6975
*/
7076
this.properties = properties || {};
7177

7278
/**
7379
* The cached image that contains the individual tiles. Use `setImage` to set.
74-
* @member {?object}
80+
* @property {?object} image
81+
* @readonly
7582
*/
7683
// Modified internally
7784
this.image = null;
7885

7986
/**
8087
* The number of rows in the tile sheet.
81-
* @member {integer}
88+
* @property {integer}
8289
* @readonly
8390
*/
8491
// Modified internally
8592
this.rows = 0;
8693

8794
/**
8895
* The number of columns in the sheet.
89-
* @member {integer}
96+
* @property {integer} columns
9097
* @readonly
9198
*/
9299
// Modified internally
93100
this.columns = 0;
94101

95102
/**
96103
* The total number of tiles in the sheet.
97-
* @member {integer}
104+
* @property {integer} total
98105
* @readonly
99106
*/
100107
// Modified internally
@@ -103,7 +110,7 @@ Phaser.Tileset = function (name, firstgid, width, height, margin, spacing, prope
103110
/**
104111
* The look-up table to specific tile image offsets.
105112
* The coordinates are interlaced such that it is [x0, y0, x1, y1 .. xN, yN] and the tile with the index of firstgid is found at indices 0/1.
106-
* @member {integer[]}
113+
* @property {integer[]} drawCoords
107114
* @private
108115
*/
109116
this.drawCoords = [];

0 commit comments

Comments
 (0)