Skip to content

Commit

Permalink
The HexagonalTileToWorldXY function incorrectly used this instead…
Browse files Browse the repository at this point in the history
… of `layer` causing it to error in hex tilemaps with x axis staggering. Fix #6913
  • Loading branch information
photonstorm committed Oct 4, 2024
1 parent 05e6fd1 commit c066ffe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tilemaps/components/HexagonalTileToWorldXY.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit c066ffe

Please sign in to comment.