Skip to content

Commit 12c6736

Browse files
committed
Stats recorded in tilesDrawn and tilesTotal.
1 parent 89db843 commit 12c6736

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

src/tilemaps/components/CullTiles.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ var CullTiles = function (layer, camera, outputArray)
4444
var boundsTop = SnapFloor(camera.worldView.y, tileH);
4545
var boundsBottom = SnapCeil(camera.worldView.bottom, tileH);
4646

47-
var i = 0;
48-
4947
for (var y = 0; y < mapHeight; y++)
5048
{
5149
for (var x = 0; x < mapWidth; x++)
@@ -57,27 +55,18 @@ var CullTiles = function (layer, camera, outputArray)
5755
continue;
5856
}
5957

60-
if (skipCull)
58+
var tilePixelX = (tile.pixelX + tilemapLayer.x) * tilemapLayer.scaleX;
59+
var tilePixelY = (tile.pixelY + tilemapLayer.y) * tilemapLayer.scaleY;
60+
61+
if (skipCull || (tilePixelX >= boundsLeft && tilePixelX + tileW <= boundsRight && tilePixelY >= boundsTop && tilePixelY + tileH <= boundsBottom))
6162
{
6263
outputArray.push(tile);
6364
}
64-
else
65-
{
66-
var tilePixelX = (tile.pixelX + tilemapLayer.x) * tilemapLayer.scaleX;
67-
var tilePixelY = (tile.pixelY + tilemapLayer.y) * tilemapLayer.scaleY;
68-
69-
if (tilePixelX >= boundsLeft && tilePixelX + tileW <= boundsRight && tilePixelY >= boundsTop && tilePixelY + tileH <= boundsBottom)
70-
{
71-
outputArray.push(tile);
72-
}
73-
}
74-
75-
i++;
7665
}
7766
}
7867

79-
window.noCull = i;
80-
window.cull = outputArray.length;
68+
tilemapLayer.tilesDrawn = outputArray.length;
69+
tilemapLayer.tilesTotal = mapWidth * mapHeight;
8170

8271
return outputArray;
8372
};

src/tilemaps/dynamiclayer/DynamicTilemapLayer.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ var DynamicTilemapLayer = new Class({
144144
*/
145145
this.skipCull = false;
146146

147+
/**
148+
* The total number of tiles drawn by the renderer in the last frame.
149+
*
150+
* @name Phaser.Tilemaps.DynamicTilemapLayer#tilesDrawn
151+
* @type {number}
152+
* @readOnly
153+
* @since 3.11.0
154+
*/
155+
this.tilesDrawn = 0;
156+
157+
/**
158+
* The total number of tiles in this layer. Updated every frame.
159+
*
160+
* @name Phaser.Tilemaps.DynamicTilemapLayer#tilesTotal
161+
* @type {number}
162+
* @readOnly
163+
* @since 3.11.0
164+
*/
165+
this.tilesTotal = this.layer.width * this.layer.height;
166+
147167
this.setAlpha(this.layer.alpha);
148168
this.setPosition(x, y);
149169
this.setOrigin();

0 commit comments

Comments
 (0)