Skip to content

Commit 2450a16

Browse files
committed
Tilemaps.Components.GetCullTilesFunction is a new function that returns the correct culling function to use.
1 parent c66df4b commit 2450a16

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 CullTiles = require('./CullTiles');
9+
var HexagonalCullTiles = require('./HexagonalCullTiles');
10+
var IsometricCullTiles = require('./IsometricCullTiles');
11+
var NOOP = require('../../utils/NOOP');
12+
var StaggeredCullTiles = require('./StaggeredCullTiles');
13+
14+
/**
15+
* Gets the correct function to use to cull tiles, based on the map orientation.
16+
*
17+
* @function Phaser.Tilemaps.Components.GetCullTilesFunction
18+
* @since 3.50.0
19+
*
20+
* @param {number} orientation - The Tilemap orientation constant.
21+
*
22+
* @return {(Phaser.Tilemaps.Components.CullTiles|Phaser.Tilemaps.Components.StaggeredCullTiles|Phaser.Tilemaps.Components.HexagonalCullTiles|Phaser.Tilemaps.Components.IsometricCullTiles)} The function to use to cull tiles for the given map type.
23+
*/
24+
var GetCullTilesFunction = function (orientation)
25+
{
26+
if (orientation === CONST.ORTHOGONAL)
27+
{
28+
return CullTiles;
29+
}
30+
else if (orientation === CONST.HEXAGONAL)
31+
{
32+
return HexagonalCullTiles;
33+
}
34+
else if (orientation === CONST.STAGGERED)
35+
{
36+
return StaggeredCullTiles;
37+
}
38+
else if (orientation === CONST.ISOMETRIC)
39+
{
40+
return IsometricCullTiles;
41+
}
42+
else
43+
{
44+
return NOOP;
45+
}
46+
};
47+
48+
module.exports = GetCullTilesFunction;

0 commit comments

Comments
 (0)