fix: Use resolved path when loading single-image tilesets#3826
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an inconsistency in
TiledAtlaspath resolution between single-image and multi-image tilesets when using external TSX files with relative image paths. When loading aRenderableTiledMapwith 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 liketiles/../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:
mappedEntry.$1(resolved image source) for loading images, matching the multi-image behaviortiledImage.source!for offset map keys, maintaining consistency with how the multi-image path stores offsetsThis ensures both code paths follow the same path resolution logic applied in
mappedImageList.Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Closes #3689