Skip to content

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

Closed
@ptantiku

Description

@ptantiku

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions