mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Tilemaps.Components.StaggeredCullTiles
is a new function that culls tiles in a staggered map.
This commit is contained in:
parent
0b8b9fb3ba
commit
ab753ffe10
1 changed files with 45 additions and 0 deletions
45
src/tilemaps/components/StaggeredCullTiles.js
Normal file
45
src/tilemaps/components/StaggeredCullTiles.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2020 Photon Storm Ltd.
|
||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
var CullBounds = require('./StaggeredCullBounds');
|
||||
var RunCull = require('./RunCull');
|
||||
|
||||
/**
|
||||
* Returns the tiles in the given layer that are within the cameras viewport. This is used internally.
|
||||
*
|
||||
* @function Phaser.Tilemaps.Components.StaggeredCullTiles
|
||||
* @since 3.50.0
|
||||
*
|
||||
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to run the cull check against.
|
||||
* @param {array} [outputArray] - An optional array to store the Tile objects within.
|
||||
* @param {integer} [renderOrder=0] - The rendering order constant.
|
||||
*
|
||||
* @return {Phaser.Tilemaps.Tile[]} An array of Tile objects.
|
||||
*/
|
||||
var StaggeredCullTiles = function (layer, camera, outputArray, renderOrder)
|
||||
{
|
||||
if (outputArray === undefined) { outputArray = []; }
|
||||
if (renderOrder === undefined) { renderOrder = 0; }
|
||||
|
||||
outputArray.length = 0;
|
||||
|
||||
var tilemapLayer = layer.tilemapLayer;
|
||||
|
||||
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
||||
{
|
||||
// Camera world view bounds, snapped for scaled tile size
|
||||
// Cull Padding values are given in tiles, not pixels
|
||||
|
||||
var bounds = CullBounds(layer, camera);
|
||||
|
||||
RunCull(layer, bounds, renderOrder, outputArray);
|
||||
}
|
||||
|
||||
return outputArray;
|
||||
};
|
||||
|
||||
module.exports = StaggeredCullTiles;
|
Loading…
Reference in a new issue