Importing SpriteSheet Using TMX File

Background Info:
I am creating a game and writing it from scratch in c++. I am using a XML parsing library and parsing TMX files myself to import maps into my game. I decided to import tilesets through the TMX file as well. Originally my tileset was a collection of separate PNGs and was importing fine. Now I am changing from using separate PNGs to using a sprite sheet.
Goal:
Import sprites into my game by using a TMX File that uses a sprite sheet.
Problem:
The information present in the TMX file is not enough to determine the location of the sprite in the sprite sheet.
The sprite sheet I’m using has empty spaces. The TMX file skips empty spaces and unused spaces when storing the tile set. So even thought the tile sheet is 320 x 352 and there should be 10 x 11 sprites in it. The TMX file tileset only has 52 tiles in it instead of 110.
Possible Solutions:

  1. If I could force the TMX format to not skip empty or unused spaces. If the tile id corresponded to it’s location on the sprite sheet I could easily figure out it’s location.
  2. Make a sprite sheet that doesn’t have empty spaces. Obviously this is the most efficient method and the sprite sheet should be this way. However I want to be able to support sprite sheets that have empty spaces.

For tilesheet images, the tile ID does actually correspond to the location on the sheet. Empty spaces aren’t skipped. The only thing that is skipped, when writing out a tileset, is redundant information. So no tile elements are written for tiles that have no data associated with them.

1 Like

You’re right. I did not see that. Thank you.

1 Like