-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
GetWorldToTileXYFunction.js
48 lines (45 loc) · 1.34 KB
/
GetWorldToTileXYFunction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var CONST = require('../const/ORIENTATION_CONST');
var HexagonalWorldToTileXY = require('./HexagonalWorldToTileXY');
var IsometricWorldToTileXY = require('./IsometricWorldToTileXY');
var NOOP = require('../../utils/NOOP');
var StaggeredWorldToTileXY = require('./StaggeredWorldToTileXY');
var WorldToTileXY = require('./WorldToTileXY');
/**
* Gets the correct function to use to translate tiles, based on the map orientation.
*
* @function Phaser.Tilemaps.Components.GetWorldToTileXYFunction
* @since 3.50.0
*
* @param {number} orientation - The Tilemap orientation constant.
*
* @return {function} The function to use to translate tiles for the given map type.
*/
var GetWorldToTileXYFunction = function (orientation)
{
if (orientation === CONST.ORTHOGONAL)
{
return WorldToTileXY;
}
else if (orientation === CONST.ISOMETRIC)
{
return IsometricWorldToTileXY;
}
else if (orientation === CONST.HEXAGONAL)
{
return HexagonalWorldToTileXY;
}
else if (orientation === CONST.STAGGERED)
{
return StaggeredWorldToTileXY;
}
else
{
return NOOP;
}
};
module.exports = GetWorldToTileXYFunction;