diff --git a/src/tilemaps/components/HexagonalGetTileCorners.js b/src/tilemaps/components/HexagonalGetTileCorners.js index 269561891e..aa443ac8cf 100644 --- a/src/tilemaps/components/HexagonalGetTileCorners.js +++ b/src/tilemaps/components/HexagonalGetTileCorners.js @@ -35,17 +35,18 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) } // Sets the center of the tile into tempVec + var tempVec = new Vector2(); var center = HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); var corners = []; - // Hard-coded orientation values for Pointy-Top Hexagons only + // We assume a pointy-top orientation (staggerAxis == 'y') var b0 = 0.5773502691896257; // Math.sqrt(3) / 3 - + var rotation = 0; var hexWidth; var hexHeight; - if (layer.staggerAxis === 'y') + if (layer.staggerAxis == 'y') { hexWidth = b0 * tileWidth; hexHeight = tileHeight / 2; @@ -54,11 +55,13 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) { hexWidth = tileWidth / 2; hexHeight = b0 * tileHeight; + rotation = 30 * Math.PI /180; } for (var i = 0; i < 6; i++) { var angle = 2 * Math.PI * (0.5 - i) / 6; + angle += rotation; corners.push(new Vector2(center.x + (hexWidth * Math.cos(angle)), center.y + (hexHeight * Math.sin(angle)))); }