Skip to content

Commit a89a58b

Browse files
committed
Restore previous function
1 parent 769850a commit a89a58b

1 file changed

Lines changed: 5 additions & 99 deletions

File tree

src/tilemaps/components/TileToWorldY.js

Lines changed: 5 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
* @license {@link https://opensource.org/licenses/MIT|MIT License}
55
*/
66

7-
8-
var CONST = require('../../const.js');
9-
107
/**
11-
* Converts from orthogonal tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
8+
* Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
129
* layer's position, scale and scroll.
1310
*
1411
* @function Phaser.Tilemaps.Components.TileToWorldY
1512
* @since 3.0.0
1613
*
17-
* @param {integer} tileY - The x coordinate, in tiles, not pixels.
14+
* @param {integer} tileY - The y coordinate, in tiles, not pixels.
1815
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
1916
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
2017
*
21-
* @return {number}
18+
* @return {number} The Y location in world coordinates.
2219
*/
23-
var OrthoTileToWorldY = function (tileY, camera, layer)
20+
var TileToWorldY = function (tileY, camera, layer)
2421
{
2522
var tileHeight = layer.baseTileHeight;
2623
var tilemapLayer = layer.tilemapLayer;
@@ -29,104 +26,13 @@ var OrthoTileToWorldY = function (tileY, camera, layer)
2926
if (tilemapLayer)
3027
{
3128
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
32-
layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));
33-
tileHeight *= tilemapLayer.scaleY;
34-
}
35-
36-
return layerWorldY + tileY * tileHeight;
37-
38-
};
39-
4029

41-
42-
/**
43-
* Converts from staggered tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
44-
* layer's position, scale and scroll.
45-
*
46-
* @function Phaser.Tilemaps.Components.StagTileToWorldY
47-
* @private
48-
* @since 3.0.0
49-
*
50-
* @param {integer} tileY - The x coordinate, in tiles, not pixels.
51-
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
52-
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
53-
*
54-
* @return {number}
55-
*/
56-
var StagTileToWorldY = function (tileY, camera, layer)
57-
{
58-
var tileHeight = layer.baseTileHeight;
59-
var tilemapLayer = layer.tilemapLayer;
60-
var layerWorldY = 0;
61-
62-
if (tilemapLayer)
63-
{
64-
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
6530
layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));
66-
tileHeight *= tilemapLayer.scaleY;
67-
}
68-
69-
70-
return layerWorldY + tileY * (tileHeight / 2);
7131

72-
};
73-
74-
75-
/**
76-
* Converts from hexagonal tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the
77-
* layer's position, scale and scroll.
78-
*
79-
* @function Phaser.Tilemaps.Components.HexTileToWorldY
80-
* @private
81-
* @since 3.0.0
82-
*
83-
* @param {integer} tileY - The x coordinate, in tiles, not pixels.
84-
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
85-
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
86-
*
87-
* @return {number}
88-
*/
89-
var HexTileToWorldY = function (tileY, camera, layer)
90-
{
91-
var tileHeight = layer.baseTileHeight;
92-
var tilemapLayer = layer.tilemapLayer;
93-
var layerWorldY = 0;
94-
95-
if (tilemapLayer)
96-
{
97-
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
98-
layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));
9932
tileHeight *= tilemapLayer.scaleY;
10033
}
101-
var sidel = layer.tilemapLayer.tilemap.hexSideLength;
102-
var rowHeight = ((tileHeight - sidel) / 2 + sidel);
103-
104-
// same as staggered
105-
return layerWorldY + tileY * rowHeight;
106-
};
107-
108-
109-
var nullFunc = function ()
110-
{
111-
console.warn('With the current map type you have to use the TileToWorldXY function.');
112-
return null;
113-
};
114-
115-
var TileToWorldY = function (orientation)
116-
{
117-
switch (orientation)
118-
{
119-
case CONST.STAGGERED:
120-
return StagTileToWorldY;
121-
case CONST.ISOMETRIC:
122-
return nullFunc;
123-
case CONST.HEXAGONAL:
124-
return HexTileToWorldY;
125-
default:
126-
return OrthoTileToWorldY;
127-
128-
}
12934

35+
return layerWorldY + tileY * tileHeight;
13036
};
13137

13238
module.exports = TileToWorldY;

0 commit comments

Comments
 (0)