Phaser Atlas Frames Wrong — Rotated and Trimmed Frame Fixes
Atlas frames that come out mirrored, turned or clipped in Phaser usually come from rotation in the atlas: in our engine runs Phaser 3.90 and 4.2 both drew rotated TexturePacker frames wrongly, without turning them back (mirrored in one run, sideways and clipped in another). Frames that are only off in Phaser 3.90 come from trimmed Starling/Sparrow XML, which its XML parser reads with two sizes swapped.
When some atlas frames come out wrong in Phaser, check the data file before the code. Entries with "rotated": true: Phaser 3.90 and 4.2 did not turn such frames back in our runs, so repack without rotation. Trimmed Starling/Sparrow XML (frameX present) in Phaser 3.90: its XML parser passes the trimmed and full sizes in the wrong order, so use the JSON atlas, trim off, or Phaser 4.2. Otherwise compare frame names and files with the loader call. Nerulio cannot patch an existing atlas; it repacks the frames with settings Phaser reads.

- Phaser 3 / 4Verified· Phaser 3.90 + 4.2
- Starling / Sparrow XMLVerified· Phaser 4.2
- Godot 4Verified· Godot 4.7.2
- Unity 6Verified· Unity 6000.5.3f1
- PixiJS 8Verified· PixiJS 8.21
- Aseprite JSONVerified· Phaser load.aseprite · PixiJS 8.21
- .asepriteVerified· Aseprite 1.3.18
- Spine / libGDXVerified· spine-canvas 4.2
- LÖVEVerified· LÖVE 11.5
- DefoldBuilt· Defold bob.jar 1.13.1
- GameMakerUNVERIFIED
- CSS spritesVerified· Chromium
- GIF / APNGDecoded· Pillow
Three causes, three places to look
Rotation. A packer may store a frame turned by 90° to save space and mark it rotated. Phaser's JSON parser flags the frame and changes its texture coordinates, but in our runs with Phaser 3.90 and 4.2 exactly the rotated frames came out wrong while the upright frames of the same atlas were right: with TexturePacker's own rotated export, 6 of 10 archer frames, 40 of 60 samurai frames and 9 of 45 toon frames matched.
Trim in XML. The Sparrow format stores the trim as frameX, frameY, frameWidth and frameHeight. Phaser 3.90's AtlasXML calls setTrim(width, height, frameX, frameY, frameWidth, frameHeight), but setTrim expects the full size first and the trimmed size last. JSON atlases are not affected, because the JSON parser passes sourceSize first.
Data mismatches. A frame name that is not in the atlas, a JSON from a different export than the PNG, or a PNG resized after packing all give wrong frames without any engine bug; they show up as wrong rectangles or missing names in this.textures.get(key).
- rotated
- Flag on a frame stored turned by 90° on the page.
- setTrim
- The Phaser Frame method that places a trimmed piece inside its full-size box.
- frameX, frameY
- Sparrow XML's negative offset of the full frame from the stored pixels.
Is it rotation or trim? Read the entry
JSON entry, rotated (TexturePacker layout):
"run_0": { "frame": {"x":17,"y":23,"w":18,"h":15}, "rotated": true, … }
→ stored as 15 × 18 on the page; Phaser 3.90 and 4.2 drew such frames wrong → repack, rotation off
Sparrow XML, trimmed:
SubTexture name="run_0" x="0" y="34" width="18" height="15" frameX="-10" frameY="-10" frameWidth="40" frameHeight="29"
Phaser 3.90 calls setTrim(18, 15, 10, 10, 40, 29)
setTrim expects setTrim(40, 29, 10, 10, 18, 15) → wrong size and offset
Phaser 4.2: correct. Fix for 3.90: the JSON atlas, or XML with trim off
JSON, trimmed (not a bug): setTrim(40, 29, 10, 10, 18, 15) from sourceSize + spriteSourceSizeIf neither flag is in the file and frames are still wrong, the cause is almost always the data: a stale JSON, a renamed frame or a resized PNG.
What it does
- The Phaser 3 / 4 preset never rotates, and the export refuses rotation even if another target had it on; the change is shown next to the Export button before you click.
- Trim stays on for the JSON atlas: Phaser reads spriteSourceSize and sourceSize correctly, so trimmed frames keep their place in both versions.
- Two XML presets: Starling / Sparrow XML keeps trim and is right in Phaser 4.2; Sparrow XML (Phaser 3) turns trim off so Phaser 3.90 draws every frame in place.
- Evidence: 49 runs in the real engines on real CC0 assets, 47 PASS. The 2 FAIL are exactly trimmed XML in Phaser 3.90, kept in the report to show the bug.
- Frames from an atlas you already made can be read back (PNG plus TexturePacker JSON or Starling XML), but frames that were rotated stay rotated, and that export path is UNVERIFIED; pack the original frames when you have them.
How to do it
- Drop the original frames, the .aseprite file or the sheet (then Apply).
- In Pack & Export choose Phaser 3 / 4: rotation off, trim on.
- For XML on Phaser 3.90 pick Sparrow XML (Phaser 3); on 4.2 either XML preset works.
- Export, load with this.load.atlas or this.load.atlasXML, and compare a few frames with the floating preview (F7).
Check the result
- Draw every frame as a still image in a grid (
this.add.image(x, y, key, name)for each name) and compare it with the source frames side by side. - If you can, try the other Phaser major version: a problem only in 3.90 with XML is the trim order; a problem in both with rotated frames is rotation.
- After repacking, the data file has no
"rotated": true, and for Phaser 3.90 XML noframeXattributes.
Atlas options in Phaser 3.90 and 4.2
| Atlas option | Phaser 3.90 | Phaser 4.2 | Studio preset |
|---|---|---|---|
| JSON hash, trimmed | Drawn right | Drawn right | Phaser 3 / 4 (trim on) |
| JSON hash, rotated frames | Drawn wrongly, not turned back | Drawn wrongly, not turned back | Rotation refused for Phaser |
| Starling/Sparrow XML, trimmed | Trimmed frames drawn wrong (setTrim gets the sizes in the wrong order) | Drawn right | Starling / Sparrow XML, for 4.2 |
| Sparrow XML, untrimmed | Drawn right | Drawn right | Sparrow XML (Phaser 3) |
| Aseprite JSON with load.aseprite | Drawn right | Drawn right | Aseprite JSON: one page, no rotation |
Troubleshooting
| Symptom | Likely cause | How to check | Fix |
|---|---|---|---|
| Only some frames are mirrored, turned or clipped | Those frames are stored rotated | "rotated": true on exactly those entries | Repack with rotation off; Nerulio's Phaser preset refuses rotation, and in TexturePacker turn Allow rotation off |
| Trimmed frames sit shifted or cropped, only in Phaser 3.90, only with XML | The AtlasXML setTrim order | The XML has frameX on those frames; the same files look right in Phaser 4.2 | "Sparrow XML (Phaser 3)" preset (trim off), the JSON atlas, or Phaser 4 |
| Every frame is offset by the same amount | With a pivot in the JSON, Phaser sets it as the sprite's origin; without one the origin is the centre | sprite.originX, sprite.originY | Expect the pivot as origin (0.5, 1 = feet), or remove pivot from the JSON if you position by the centre |
| Frames show pictures from other frames | The JSON and the PNG come from different exports, or frame names changed | Compare meta.image and meta.size with the PNG; list this.textures.get(key).getFrameNames() | Export both files again, together |
| Frames blur or show seams while moving | Linear filtering and positions between pixels, not the atlas data | The game config | pixelArt: true, and keep 2 px padding in the atlas |
Other ways to do it
| Option | When it is the better choice |
|---|---|
Aseprite JSON with this.load.aseprite | Drawn correctly in Phaser 3.90 and 4.2 in our runs; one page, no rotation. See Aseprite to Phaser. |
| Repack from the original frames | Best when you have them: the Phaser 3 / 4 preset keeps trim and never rotates; see Phaser texture atlas. Reading frames back from an existing atlas keeps rotated frames turned. |
Engine exports and how each was checked
"Verified" means the exported files were loaded by the real engine or tool on real CC0 assets and the result was compared with the source. Anything that was not loaded is labelled as such.
| Target | Files | Check |
|---|---|---|
| Godot 4 | .tres SpriteFrames · .tscn AnimatedSprite2D · .png.import | Verified Godot 4.7.2Loaded by Godot; every animation frame drawn and compared with the source file. The scene uses Nearest filtering; rotation is never used. |
| Unity 6 | .unity.json · Editor/NerulioSpriteImporter.cs · AnimationClip | Verified Unity 6000.5.3f1Batch mode: sprite rects, pivots, pixels, clip keys and durations checked. |
| Phaser 3 / 4 | atlas JSON (multiatlas) · .anims.json | Verified Phaser 3.90 + 4.2Frames and animations drawn by both versions. |
| PixiJS 8 | spritesheet JSON · animations · anchor · meta.scale | Verified PixiJS 8.21Rotated and multi-page atlases included. |
| Aseprite JSON | hash / array · frameTags · slices | Verified Phaser load.aseprite · PixiJS 8.21Tags keep their direction and repeat count. |
| .aseprite | layers · tags · durations · slices | Verified Aseprite 1.3.18Opened and rendered by the Aseprite command line. |
| Spine / libGDX | .atlas | Verified spine-canvas 4.2Every region drawn by the Spine runtime, rotated and trimmed; libGDX itself was not run. |
| Starling / Sparrow XML | XML per page | Verified Phaser 4.2Phaser 3.90 draws trimmed XML frames wrongly (its own bug); the "Sparrow XML (Phaser 3)" preset turns trim off and passes in 3.90 and 4.2. |
| LÖVE | Lua quads · nerulio_atlas.lua · main.lua | Verified LÖVE 11.5Every frame drawn and every animation stepped through the shipped helper. |
| Defold | .atlas · .tilesource | Built Defold bob.jar 1.13.1Built by Defold's command-line builder; the built texture's UVs were read back. |
| GameMaker | spr_<name>_stripN.png · gamemaker.json | UNVERIFIEDNot loaded in GameMaker (no headless GameMaker). The strips are cut the way its strip importer cuts them. |
| CSS sprites | .css · preview .html | Verified ChromiumEvery class drawn from the shipped stylesheet. |
| GIF / APNG | one file per animation | Decoded PillowEvery frame and delay decoded again after export; APNG is exact. |
Evidence
Exports: 49 runs in the real engines on real CC0 assets, 47 pass — the 2 failures are Phaser 3.90's trimmed-XML bug, which the Phaser 3 preset avoids. Packer head-to-head on 5 real frame sets (CodeAndWeb free web packer, GAPTools, free-tex-packer): smallest sheet on all 5 with rotation allowed, 4 of 5 without; every frame restored pixel-exact.
Limits
- Polygon (mesh) packing is not offered: none of the verified engines draws a mesh atlas from exported data.
- GameMaker strips are UNVERIFIED in GameMaker itself.
- Scale variants (@0.5x–@4x) use nearest-neighbour only.
- Trimmed Starling XML is drawn wrongly by Phaser 3.90; use the "Sparrow XML (Phaser 3)" preset there.
Versions and sources
In Nerulio's engine runs of 2026-09-23, 49 Studio exports were loaded in real engines: 47 passed and the 2 failures were trimmed Starling XML in Phaser 3.90. Rotated TexturePacker frames failed in both Phaser 3.90.0 and 4.2.1, including TexturePacker 8.3.0's own export with rotation enabled (2026-09-25). The setTrim orders are quoted from the Phaser 3.90 source.
Official documentation used
Questions
Can I keep rotation on for Phaser?
Not with these versions: in our runs Phaser 3.90 and 4.2 did not turn rotated TexturePacker frames back, so the Phaser preset never rotates. PixiJS 8.21 and the Spine runtime did draw rotated frames correctly, and their presets may rotate.
Does Phaser 4 still have the XML trim problem?
No. Phaser 4.2 drew trimmed Starling/Sparrow XML right in the same runs. Rotation is the one problem both versions share.
What does turning trim off cost?
Each frame keeps its whole canvas, transparent border included, so the page gets larger. If you can use the JSON atlas instead of XML, keep trim on there.
Can I fix the atlas file I already have?
Only by re-packing. The Studio does not patch an existing atlas; it packs the frames again with settings Phaser reads correctly.
Is it free, and do I need an account?
Everything on these pages is free and works without an account. There is no watermark and no export that is held back.
Are my sprites uploaded?
No. The Studio decodes, packs and exports in this browser tab. Projects are autosaved in the browser (IndexedDB) and can be saved as a .nerulio file.
Does it need Aseprite or an engine plugin installed?
No. .aseprite files are read and written in the browser, and each engine bundle carries what that engine needs (for Godot, the import settings and scene; for Unity and the Godot TileSet, a small editor script).