karai17 / Simple-Tiled-Implementation

Tiled library for LÖVE
Other
853 stars 121 forks source link

Image collection support with texture atlases #273

Closed coz-eduardo-hernandez closed 2 years ago

coz-eduardo-hernandez commented 2 years ago

Issue #173

These are the smallest number of commits from my repo that give support to Image collections:

  1. Changes a variable assignment that did not have to depend on a global tileset height
  2. Adds the Tiled map/tileset files for testing
  3. Adds a file/module called 'atlas.lua' which does the actual loading. Even though it's a separate file, I'm not sure how to implement it as a pure plugin without touching STI code.
  4. Changes STI code to use the atlas module; the most significant change is adding the function setAtlasTiles as an alternative to setTiles when an atlas is used
  5. After making the pull request I tested it with a pet project, and found that I needed to add utils.format_path, so I added this commit
  6. Skips handling the tileset images in a collection if the tileset is empty, and adds an update to the test map to test for it

Regarding the fourth commit: at some point Tiled stopped exporting the tileset image filename when the tileset is external (non-embedded), so now there's an assert in Map:init for external tilesets, since maps with them will not load.

To run the Image collection test just run main.lua.

karai17 commented 2 years ago

Looks good! Thanks for implementing this!

Serif-7 commented 2 years ago

Lol, I literally was dealing with this problem a few hours ago and realized I had to embed the tilesets. If I had that clear error message you wrote it would have saved me some time!

coz-eduardo-hernandez commented 2 years ago

Lol, I literally was dealing with this problem a few hours ago and realized I had to embed the tilesets. If I had that clear error message you wrote it would have saved me some time!

At the time of the last release of STI external Tilesets were supported, but Tiled changed what information it exports, so now the previous approach to external Tilesets won't work