Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculation for widthInPixels and heightInPixels in MapData class does not consider orientation="hexagonal" #6992

Open
ptantiku opened this issue Dec 21, 2024 · 0 comments

Comments

@ptantiku
Copy link

Version

  • Phaser Version: 3.87.0
  • Operating system:

Description

When using a tilemap with orientation="hexagonal", each pair of adjacent hexagonal tiles partially overlaps, reducing the overall width and height of the tilemap compared to a rectangular grid.

However, the current calculation for widthInPixels and heightInPixels simply multiplies the number of tiles by their width or height, without accounting for the hexagonal overlap. This results in incorrect dimensions for hexagonal tilemaps, causing layout and rendering inconsistencies.

Example Test Code

Example Code & Suggestion: https://phaser.io/sandbox/8BSZFoKz

Additional Information

The red rectangle uses widthInPixels and heightInPixels.
The green rectangle is what they should be.
image

I think the issue comes from

this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.tileWidth);

this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.tileHeight);

and my suggested calculation is in the example code above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant