From 077d933bbb76e49566cd01321dbdd9a666725540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bugi=20Go=CC=88rtz?= Date: Thu, 15 Mar 2018 20:32:09 +0100 Subject: [PATCH] Fixed Tile-Culling for Zoomed Camera The fix from https://github.com/photonstorm/phaser/pull/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) --- src/tilemaps/components/CullTiles.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index 2aadfa4d4..4feb0bf85 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -14,7 +14,7 @@ * @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] - [description] - * + * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ var CullTiles = function (layer, camera, outputArray) @@ -27,8 +27,8 @@ var CullTiles = function (layer, camera, outputArray) var mapData = layer.data; var mapWidth = layer.width; var mapHeight = layer.height; - var left = (camera.scrollX * tilemapLayer.scrollFactorX) - tilemapLayer.x; - var top = (camera.scrollY * tilemapLayer.scrollFactorY) - tilemapLayer.y; + var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x; + var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y; var sx = tilemapLayer.scaleX; var sy = tilemapLayer.scaleY; var tileWidth = layer.tileWidth * sx;