Skip to content

fix: Path Resolution and Region Parsing #3849

Open
s1r1m1r1 wants to merge 5 commits intoflame-engine:mainfrom
s1r1m1r1:main
Open

fix: Path Resolution and Region Parsing #3849
s1r1m1r1 wants to merge 5 commits intoflame-engine:mainfrom
s1r1m1r1:main

Conversation

@s1r1m1r1
Copy link
Contributor

@s1r1m1r1 s1r1m1r1 commented Mar 6, 2026

Description

This proposal introduces several key improvements to
TexturePackerAtlas
to make it more robust when working with modular projects, flutter_gen, and various TexturePacker export settings.

Checklist

  • I have followed the [Contributor Guide] when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • 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.

HOTFIX

  • After implementation, I found errors that I corrected in this request.

1. Handling Region Names with File Extensions

Some TexturePacker export configurations include file extensions (e.g., .png) for individual regions within the .atlas file. The current parser treats any line ending in a common image extension as a new page header.

Change: Added "peeking" logic to the parser. If a line ends in an image extension but is immediately followed by region-specific properties (like bounds:, offsets:), it is correctly treated as a region name rather than a new page.

2. Automatic Index Extraction from Numeric Suffixes

Region names often follow conventions like sprite_01.png, sprite_02.png. In LibGDX/Flame, these are intended to be grouped as the same region with different indexes.

Change: If a region name has a numeric suffix (e.g., _01) and no explicit index: property is provided in the atlas file, the suffix is extracted and used as the index. This allows findSpritesByName to correctly identify frames for SpriteAnimation.spriteList.

Regression Tests

I've added comprehensive tests in atlas_path_resolution_test.dart covering:

  • Auto-detection of package from complex paths.
  • Correct parsing of atlas files where region names contain .png.
  • Successful extraction of indexes from region names with suffixes.

s1r1m1r1 and others added 4 commits March 6, 2026 18:39
Prepared all packages to be released to pub.dev

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@s1r1m1r1 s1r1m1r1 changed the title fix: [flame_texturepacker] Path Resolution and Region Parsing fix: [flame_texturepacker] #3848 Path Resolution and Region Parsing Mar 6, 2026
Copy link
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.

Analyzing flame_texturepacker...

info • The line length exceeds the 80-character limit • lib/src/texture_packer_atlas.dart:268:81 • lines_longer_than_80_chars

info • The line length exceeds the 80-character limit • lib/src/texture_packer_atlas.dart:276:81 • lines_longer_than_80_chars

@spydon spydon changed the title fix: [flame_texturepacker] #3848 Path Resolution and Region Parsing fix: Path Resolution and Region Parsing Mar 6, 2026
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.

2 participants