Skip to content

Commit 92b4316

Browse files
committed
Tilemaps.Components.GetWorldToTileYFunction is a new function that returns the correct type of translation to use.
1 parent f1c85fc commit 92b4316

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 HexagonalWorldToTileY = require('./HexagonalWorldToTileY');
9+
var NOOP = require('../../utils/NOOP');
10+
var StaggeredWorldToTileY = require('./StaggeredWorldToTileY');
11+
var WorldToTileY = require('./WorldToTileY');
12+
13+
/**
14+
* Gets the correct function to use to translate tiles, based on the map orientation.
15+
*
16+
* @function Phaser.Tilemaps.Components.GetWorldToTileYFunction
17+
* @since 3.50.0
18+
*
19+
* @param {number} orientation - The Tilemap orientation constant.
20+
*
21+
* @return {(Phaser.Tilemaps.Components.WorldToTileY|Phaser.Tilemaps.Components.HexagonalWorldToTileY|Phaser.Tilemaps.Components.StaggeredWorldToTileY)} The function to use to translate tiles for the given map type.
22+
*/
23+
var GetWorldToTileYFunction = function (orientation)
24+
{
25+
if (orientation === CONST.ORTHOGONAL)
26+
{
27+
return WorldToTileY;
28+
}
29+
else if (orientation === CONST.HEXAGONAL)
30+
{
31+
return HexagonalWorldToTileY;
32+
}
33+
else if (orientation === CONST.STAGGERED)
34+
{
35+
return StaggeredWorldToTileY;
36+
}
37+
else
38+
{
39+
return NOOP;
40+
}
41+
};
42+
43+
module.exports = GetWorldToTileYFunction;

0 commit comments

Comments
 (0)