Skip to content

Commit b09197d

Browse files
committed
Added proper JSDocs and fixed private accessors phaserjs#4922
1 parent d5561ad commit b09197d

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

src/tilemaps/Tilemap.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,25 @@ var Tilemap = new Class({
262262
*/
263263
this.hexSideLength = mapData.hexSideLength;
264264

265+
var orientation = this.orientation;
266+
265267
/**
266-
* Components used for conversions between real world coordinates and tile coordinates,
267-
* initialized here to prevent switching between them at runtime depending on map orientation.
268-
* refer to the components themselves for documentation.
269-
* @since 3.2.2
268+
* Functions used to handle world to tile, and tile to world, conversion.
269+
* Cached here for internal use by public methods such as `worldToTileXY`, etc.
270+
*
271+
* @name Phaser.Tilemaps.Tilemap#_convert
272+
* @private
273+
* @type {object}
274+
* @since 3.50.0
270275
*/
271-
this.WorldToTileXY = TilemapComponents.WorldToTileXY(this.orientation);
272-
this.WorldToTileX = TilemapComponents.WorldToTileX(this.orientation);
273-
this.WorldToTileY = TilemapComponents.WorldToTileY(this.orientation);
274-
this.TileToWorldXY = TilemapComponents.TileToWorldXY(this.orientation);
275-
this.TileToWorldX = TilemapComponents.TileToWorldX(this.orientation);
276-
this.TileToWorldY = TilemapComponents.TileToWorldY(this.orientation);
276+
this._convert = {
277+
WorldToTileXY: TilemapComponents.GetWorldToTileXYFunction(orientation),
278+
WorldToTileX: TilemapComponents.GetWorldToTileXFunction(orientation),
279+
WorldToTileY: TilemapComponents.GetWorldToTileYFunction(orientation),
280+
TileToWorldXY: TilemapComponents.GetTileToWorldXYFunction(orientation),
281+
TileToWorldX: TilemapComponents.GetTileToWorldXFunction(orientation),
282+
TileToWorldY: TilemapComponents.GetTileToWorldYFunction(orientation)
283+
};
277284
},
278285

279286
/**
@@ -2369,7 +2376,7 @@ var Tilemap = new Class({
23692376

23702377
if (layer === null) { return null; }
23712378

2372-
return this.TileToWorldX(tileX, camera, layer);
2379+
return this._convert.TileToWorldX(tileX, camera, layer);
23732380
},
23742381

23752382
/**
@@ -2394,7 +2401,7 @@ var Tilemap = new Class({
23942401

23952402
if (layer === null) { return null; }
23962403

2397-
return this.TileToWorldY(tileX, camera, layer);
2404+
return this._convert.TileToWorldY(tileX, camera, layer);
23982405
},
23992406

24002407
/**
@@ -2422,7 +2429,7 @@ var Tilemap = new Class({
24222429

24232430
if (layer === null) { return null; }
24242431

2425-
return this.TileToWorldXY(tileX, tileY, point, camera, layer);
2432+
return this._convert.TileToWorldXY(tileX, tileY, point, camera, layer);
24262433
},
24272434

24282435
/**
@@ -2493,7 +2500,7 @@ var Tilemap = new Class({
24932500

24942501
if (layer === null) { return null; }
24952502

2496-
return this.WorldToTileX(worldX, snapToFloor, camera, layer);
2503+
return this._convert.WorldToTileX(worldX, snapToFloor, camera, layer);
24972504
},
24982505

24992506
/**
@@ -2518,7 +2525,7 @@ var Tilemap = new Class({
25182525

25192526
if (layer === null) { return null; }
25202527

2521-
return this.WorldToTileY(worldY, snapToFloor, camera, layer);
2528+
return this._convert.WorldToTileY(worldY, snapToFloor, camera, layer);
25222529
},
25232530

25242531
/**
@@ -2546,7 +2553,7 @@ var Tilemap = new Class({
25462553

25472554
if (layer === null) { return null; }
25482555

2549-
return this.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer);
2556+
return this._convert.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer);
25502557
},
25512558

25522559
/**

0 commit comments

Comments
 (0)