Skip to content

fix: Use resolved path when loading single-image tilesets#3826

Merged
spydon merged 2 commits intomainfrom
devkage/single-image-loading-fix
Mar 1, 2026
Merged

fix: Use resolved path when loading single-image tilesets#3826
spydon merged 2 commits intomainfrom
devkage/single-image-loading-fix

Conversation

@ufrshubham
Copy link
Copy Markdown
Member

Description

Fixes an inconsistency in TiledAtlas path resolution between single-image and multi-image tilesets when using external TSX files with relative image paths. When loading a RenderableTiledMap with a single image from an external TSX tileset that references images using relative paths, the image loading would fail. The single-image code path was using the atlas key (original relative path like ../images/name.png) to load the image, while the multi-image code path correctly used the resolved path (tileset directory + relative path like tiles/../images/name.png).

This inconsistency meant that maps with one image would fail to load in scenarios where maps with multiple images would succeed.

Updated the single-image path to:

  • Use mappedEntry.$1 (resolved image source) for loading images, matching the multi-image behavior
  • Use tiledImage.source! for offset map keys, maintaining consistency with how the multi-image path stores offsets

This ensures both code paths follow the same path resolution logic applied in mappedImageList.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • [NA] I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [NA] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #3689

@ufrshubham ufrshubham self-assigned this Mar 1, 2026
@ufrshubham ufrshubham changed the title Test relative image path in tileset atlas fix: Use resolved path when loading single-image tilesets Mar 1, 2026
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes TiledAtlas so single-image tilesets loaded from external TSX files use the same resolved image path logic as multi-image tilesets, preventing failures when TSX image sources are relative.

Changes:

  • Update the single-image tileset loading path to load the image using the resolved image source (mappedEntry.$1) rather than the atlas key.
  • Align single-image offsets map keying with the multi-image path by using tiledImage.source!.
  • Add a regression test covering a single-image tileset with a TSX-relative image path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/flame_tiled/lib/src/tile_atlas.dart Makes single-image tileset image loading use the resolved image path, matching the multi-image path behavior.
packages/flame_tiled/test/tile_atlas_test.dart Adds a test reproducing the TSX-relative single-image failure and validating the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spydon spydon merged commit bbdff92 into main Mar 1, 2026
14 checks passed
@spydon spydon deleted the devkage/single-image-loading-fix branch March 1, 2026 21:19
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.

Single image map loading issue

3 participants