Game asset processing3 min read

Tiled flipped tiles look wrong? Clear the GID flags first

Use two GIDs and one firstgid to isolate a Tiled import error in tile lookup or orientation.

Tiled flipped tiles look wrong? Clear the GID flags first
Two mirrored arrow tiles beside a tiled dungeon board
Concept illustration

If ordinary floor tiles render and mirrored ones disappear, check the raw global tile IDs before rebuilding the atlas. This fixture is for a custom reader of orthogonal tile layers exported from Tiled as TMX or JSON.

Trace one tile through the importer

  1. Create a tiny map with one tileset. Check that its exported firstgid is 1. Paint the first tile, a right-facing floor arrow, into two cells. Flip the second copy horizontally.
  2. Read each exported value as an unsigned 32-bit integer. The expected pair is 0x00000001 and 0x80000001. Capture the high four bits before using gid & 0x0FFFFFFF to obtain the underlying GID.
  3. Treat clean ID zero as empty. Otherwise, select the tileset with the greatest firstgid that does not exceed the clean ID, then subtract it. Both cells should resolve to local index zero. Only the second copy gets a horizontal flip at render time.

Check the lookup and transform separately

If both cells resolve to the same artwork but face the wrong way, inspect the transform sequence. On an orthogonal map, apply diagonal flipping before horizontal and vertical flipping. Clear all four high bits during lookup, including the hex rotation bit, which can survive an orientation change. Use Sprite Sheet Packer to prepare the artwork and keep GID and orientation checks in your importer.

Recommended tools

Ready to try "Tiled flipped tiles look wrong? Clear the GID flags first"?

Use our online tools to apply this tutorial to your indie game project right away.