Skip to content

Commit 86965c2

Browse files
committed
The Tilemap Culling function now uses the Tilemap tile dimensions for its bounds calculations, instead of the layer tile sizes, as they two don't have to match and it's the underlying grid size that takes precedence when calculating visible tiles. Fix phaserjs#3893
1 parent 41c9f8b commit 86965c2

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ The Tile Sprite Game Object has been given an internal overhaul to make it more
137137
* The Canvas Renderer has a new `batchSprite` method that consolidates the process of drawing a texture-based Game Object to the canvas. It processes the alpha, blend mode and matrix calculations in a single function and now is used by nearly all Game Object canvas renderers.
138138
* The `batchTexture` method in the Texture Tint Pipeline now supports cropped Game Objects and will adjust the drawn texture frame accordingly.
139139
* The `Matrix Stack` Component has been removed. It's no longer used internally and was just wasting space.
140+
* You can now specify the `lineHeight` of a Retro Font in the Retro Font Config object (thanks @FelixNemis)
140141

141142
### Game Config Resolution Specific Bug Fixes
142143

@@ -170,6 +171,9 @@ Setting the `resolution` property in the Game Config to a value other than 1 wou
170171
* The `CullTiles` updates from 3.11 didn't factor in the position of the Tilemap Layer to its bounds calculations, causing Static layers displayed out of the Camera viewport to never render in Canvas mode. The method has also been optimized further, with less divisions and less checks if culling is disabled.
171172
* The Particle Emitter when running in Canvas wouldn't allow more than 1 emitter to use a blend mode (as seen in the Electric examples). The blend mode is properly set for each emitter now.
172173
* The Blend Mode is now set directly in all Canvas Renderers without comparing it to what's stored in the Canvas Renderer. This fixes problems where the blend mode would be lost between two different Game Objects because they restored the context, but didn't update the renderer flag. Game Objects in Canvas can now mix and match blend modes across the display list.
174+
* Matter.js has received a tiny update that prevents `collisionEnd` from triggering many times when it should only trigger once (thanks @mikewesthad)
175+
* Graphics objects couldn't be set to be ignored by Cameras. Now every renderable Game Object can be ignored by a Camera, either directly or via a Container. The exception are Groups because they don't render and are non-exclusive parents.
176+
* The Tilemap Culling function now uses the Tilemap tile dimensions for its bounds calculations, instead of the layer tile sizes, as they two don't have to match and it's the underlying grid size that takes precedence when calculating visible tiles. Fix #3893 (thanks @Zax37)
173177

174178
### Examples, Documentation and TypeScript
175179

src/tilemaps/components/CullTiles.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ var CullTiles = function (layer, camera, outputArray)
2727

2828
outputArray.length = 0;
2929

30+
var tilemap = layer.tilemapLayer.tilemap;
3031
var tilemapLayer = layer.tilemapLayer;
3132

3233
var mapData = layer.data;
3334
var mapWidth = layer.width;
3435
var mapHeight = layer.height;
3536

36-
var tileW = Math.floor(layer.tileWidth * tilemapLayer.scaleX);
37-
var tileH = Math.floor(layer.tileHeight * tilemapLayer.scaleY);
37+
// We need to use the tile sizes defined for the map as a whole, not the layer,
38+
// in order to calculate the bounds correctly. As different sized tiles may be
39+
// placed on the grid and we cannot trust layer.baseTileWidth to give us the true size.
40+
var tileW = Math.floor(tilemap.tileWidth * tilemapLayer.scaleX);
41+
var tileH = Math.floor(tilemap.tileHeight * tilemapLayer.scaleY);
3842

3943
var drawLeft = 0;
4044
var drawRight = mapWidth;

0 commit comments

Comments
 (0)