Skip to content

Commit 0b63075

Browse files
committed
Tilemaps.Components.GetTileToWorldYFunction is a new function that returns the correct conversion function to use.
1 parent 00603c0 commit 0b63075

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2020 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
var CONST = require('../const');
8+
var HexagonalTileToWorldY = require('./HexagonalTileToWorldY');
9+
var NOOP = require('../../utils/NOOP');
10+
var StaggeredTileToWorldY = require('./StaggeredTileToWorldY');
11+
var TileToWorldY = require('./TileToWorldY');
12+
13+
/**
14+
* Gets the correct function to use to translate tiles, based on the map orientation.
15+
*
16+
* @function Phaser.Tilemaps.Components.GetTileToWorldYFunction
17+
* @since 3.50.0
18+
*
19+
* @param {number} orientation - The Tilemap orientation constant.
20+
*
21+
* @return {(Phaser.Tilemaps.Components.TileToWorldY|Phaser.Tilemaps.Components.HexagonalTileToWorldY|Phaser.Tilemaps.Components.StaggeredTileToWorldY)} The function to use to translate tiles for the given map type.
22+
*/
23+
var GetTileToWorldYFunction = function (orientation)
24+
{
25+
if (orientation === CONST.ORTHOGONAL)
26+
{
27+
return TileToWorldY;
28+
}
29+
else if (orientation === CONST.HEXAGONAL)
30+
{
31+
return HexagonalTileToWorldY;
32+
}
33+
else if (orientation === CONST.STAGGERED)
34+
{
35+
return StaggeredTileToWorldY;
36+
}
37+
else
38+
{
39+
return NOOP;
40+
}
41+
};
42+
43+
module.exports = GetTileToWorldYFunction;

0 commit comments

Comments
 (0)