From c066ffef1bc0abc98bede1a7d8d8df5ceb32204c Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 4 Oct 2024 15:53:27 +0100 Subject: [PATCH] The `HexagonalTileToWorldXY` function incorrectly used `this` instead of `layer` causing it to error in hex tilemaps with x axis staggering. Fix #6913 --- src/tilemaps/components/HexagonalTileToWorldXY.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tilemaps/components/HexagonalTileToWorldXY.js b/src/tilemaps/components/HexagonalTileToWorldXY.js index 9810a5facb..94cb9a9dc2 100644 --- a/src/tilemaps/components/HexagonalTileToWorldXY.js +++ b/src/tilemaps/components/HexagonalTileToWorldXY.js @@ -52,15 +52,17 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer) var x; var y; + var staggerAxis = layer.staggerAxis; + var staggerIndex = layer.staggerIndex; - if (layer.staggerAxis === 'y') + if (staggerAxis === 'y') { x = worldX + (tileWidth * tileX) + tileWidth; y = worldY + ((1.5 * tileY) * tileHeightHalf) + tileHeightHalf; if (tileY % 2 === 0) { - if (this.staggerIndex === 'odd') + if (staggerIndex === 'odd') { x -= tileWidthHalf; } @@ -70,14 +72,14 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer) } } } - else if ((this.staggerAxis === 'x') && (this.staggerIndex === 'odd')) + else if ((staggerAxis === 'x') && (staggerIndex === 'odd')) { x = worldX + ((1.5 * tileX) * tileWidthHalf) + tileWidthHalf; y = worldY + (tileHeight * tileX) + tileHeight; if (tileX % 2 === 0) { - if (this.staggerIndex === 'odd') + if (staggerIndex === 'odd') { y -= tileHeightHalf; }