From 81c800986b04451923d7de6a01c404a49f62f358 Mon Sep 17 00:00:00 2001 From: Ulf Kamp <49397600+ukamp@users.noreply.github.com> Date: Sat, 25 May 2024 17:25:15 +0200 Subject: [PATCH 1/3] Fixed HexagonalGetTileCorners.js - Declaration of tempVec was missing - Added rotation for staggerAxis = x --- src/tilemaps/components/HexagonalGetTileCorners.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tilemaps/components/HexagonalGetTileCorners.js b/src/tilemaps/components/HexagonalGetTileCorners.js index 269561891e..3e480f3763 100644 --- a/src/tilemaps/components/HexagonalGetTileCorners.js +++ b/src/tilemaps/components/HexagonalGetTileCorners.js @@ -35,13 +35,13 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) } // Sets the center of the tile into tempVec - var center = HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); + var tempVec = new Phaser.Math.Vector2; + var center = this.HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); var corners = []; - // Hard-coded orientation values for Pointy-Top Hexagons only var b0 = 0.5773502691896257; // Math.sqrt(3) / 3 - + var rotation = 0; var hexWidth; var hexHeight; @@ -54,13 +54,15 @@ 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)))); + corners.push(new Phaser.Math.Vector2(center.x + (hexWidth * Math.cos(angle)), center.y + (hexHeight * Math.sin(angle)))); } return corners; From e4a327c9eee6b4a5ec8aaf31bdb2d9e16f55ac16 Mon Sep 17 00:00:00 2001 From: Ulf Kamp <49397600+ukamp@users.noreply.github.com> Date: Sat, 25 May 2024 17:33:48 +0200 Subject: [PATCH 2/3] Update HexagonalGetTileCorners.js changed this.HexagonalTileToWorldXY (left over from labs.phaser.io test) to HexagonalTileToWorldXY --- src/tilemaps/components/HexagonalGetTileCorners.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tilemaps/components/HexagonalGetTileCorners.js b/src/tilemaps/components/HexagonalGetTileCorners.js index 3e480f3763..6ada01a5b8 100644 --- a/src/tilemaps/components/HexagonalGetTileCorners.js +++ b/src/tilemaps/components/HexagonalGetTileCorners.js @@ -36,7 +36,7 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) // Sets the center of the tile into tempVec var tempVec = new Phaser.Math.Vector2; - var center = this.HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); + var center = HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); var corners = []; From 3b0e75049d005067b9ce3d0f22317376247cc8e2 Mon Sep 17 00:00:00 2001 From: Ulf Kamp <49397600+ukamp@users.noreply.github.com> Date: Sun, 26 May 2024 11:53:10 +0200 Subject: [PATCH 3/3] Update HexagonalGetTileCorners.js --- src/tilemaps/components/HexagonalGetTileCorners.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tilemaps/components/HexagonalGetTileCorners.js b/src/tilemaps/components/HexagonalGetTileCorners.js index 6ada01a5b8..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 Phaser.Math.Vector2; + var tempVec = new Vector2(); var center = HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); var corners = []; + // 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; @@ -62,7 +63,7 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) var angle = 2 * Math.PI * (0.5 - i) / 6; angle += rotation; - corners.push(new Phaser.Math.Vector2(center.x + (hexWidth * Math.cos(angle)), center.y + (hexHeight * Math.sin(angle)))); + corners.push(new Vector2(center.x + (hexWidth * Math.cos(angle)), center.y + (hexHeight * Math.sin(angle)))); } return corners;