Skip to content

Commit 077d933

Browse files
committed
Fixed Tile-Culling for Zoomed Camera
The fix from phaserjs#3354 leads to some tiles getting culled when camera is zoomed as the camera.scrollX/camera.scrollY-Properties are needed in unscaled Coordinates (World-Coordinates?) in CullTile.js Error gets bigger with distance from (0|0)
1 parent d966aaa commit 077d933

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/tilemaps/components/CullTiles.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
1515
* @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against.
1616
* @param {array} [outputArray] - [description]
17-
*
17+
*
1818
* @return {Phaser.Tilemaps.Tile[]} An array of Tile objects.
1919
*/
2020
var CullTiles = function (layer, camera, outputArray)
@@ -27,8 +27,8 @@ var CullTiles = function (layer, camera, outputArray)
2727
var mapData = layer.data;
2828
var mapWidth = layer.width;
2929
var mapHeight = layer.height;
30-
var left = (camera.scrollX * tilemapLayer.scrollFactorX) - tilemapLayer.x;
31-
var top = (camera.scrollY * tilemapLayer.scrollFactorY) - tilemapLayer.y;
30+
var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x;
31+
var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y;
3232
var sx = tilemapLayer.scaleX;
3333
var sy = tilemapLayer.scaleY;
3434
var tileWidth = layer.tileWidth * sx;

0 commit comments

Comments
 (0)