Skip to content

fix(flame_tiled): Anchor oversized orthogonal tiles at bottom-left of cell#3923

Open
Ortes wants to merge 1 commit into
flame-engine:mainfrom
Ortes:fix/tile-anchor-oversized-collection-images
Open

fix(flame_tiled): Anchor oversized orthogonal tiles at bottom-left of cell#3923
Ortes wants to merge 1 commit into
flame-engine:mainfrom
Ortes:fix/tile-anchor-oversized-collection-images

Conversation

@Ortes
Copy link
Copy Markdown

@Ortes Ortes commented May 14, 2026

Fixes #3922.

Summary

For oversized tiles in orthogonal maps (image larger than map.tileWidth/tileHeight, typically collection-image tilesets used for decorative props like trees), flame_tiled was anchoring the rendered image at the cell's bottom-right, causing it to extend up and to the left. Tiled's editor anchors such tiles at the cell's bottom-left (extending up and to the right). The mismatch broke tileoffset-based workflows: a tile visually centered on its cell in Tiled was rendered off-cell in-game.

Change

- final anchorX = src.width - halfMapTile.x;
+ final anchorX = halfMapTile.x;

For uniform tilesets where src.width == map.tileWidth, both expressions equal halfMapTile.x, so the common case is unchanged. The fix only affects tiles whose source image is larger than the map's tile size.

The isometric, hexagonal, and staggered renderers have their own anchor logic and are not touched.

Test plan

  • oversized_tiles_orthogonal golden regenerated (it previously captured the buggy bottom-right anchoring; it now captures the corrected bottom-left anchoring per Tiled's convention)
  • All other tests in flame_tiled continue to pass (the 3 unrelated pre-existing failures on mainimage_layer_test "covers entire map" and TileStack positioning — are unaffected by this change)
  • Verified visually in a downstream project: a 117×141 tree tile from a collection-image tileset with tileoffset.x="-43" (placed in Tiled to center the trunk on a 32×32 cell) now renders centered in-game, matching the Tiled editor preview

Compatibility note

For users who currently have oversized orthogonal tiles and worked around the bug by tweaking tileoffset to compensate for the bottom-right anchoring, this change will shift those tiles visually. The new behavior matches Tiled's editor, so re-opening the map in Tiled will show the same result as in-game.

… cell

In Tiled, when a tile image is larger than the map's tile size (oversized
tiles from collection-image tilesets, or atlas tiles drawn into a smaller
map cell), the image is rendered with its bottom-LEFT corner aligned to
the cell's bottom-left, extending up and to the right.

flame_tiled's orthogonal renderer instead anchored such tiles at the
cell's bottom-RIGHT (`anchorX = src.width - halfMapTile.x`), causing
oversized tiles to extend up and to the LEFT, which does not match
Tiled's editor preview and breaks `tileoffset` workflows: positioning a
tree centered on its cell in Tiled placed it off-cell in-game.

For uniform tilesets where `src.width == map.tileWidth`, the new
`anchorX = halfMapTile.x` evaluates to the same value as before, so
behavior is unchanged for the common case.

The `oversized_tiles_orthogonal` golden was regenerated to reflect the
corrected (Tiled-compatible) rendering. The isometric, hexagonal, and
staggered renderers are not touched by this change.
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

Successfully merging this pull request may close these issues.

[flame_tiled] Oversized orthogonal tiles anchor at cell's bottom-right instead of bottom-left

1 participant