megamarc / Tilengine

Free 2D graphics engine with raster effects for retro/classic style game development
https://www.tilengine.org
Mozilla Public License 2.0
847 stars 95 forks source link

Tileset ordering in tmx file causing exception #113

Closed danielgholmes closed 1 month ago

danielgholmes commented 1 year ago

From the .tmx file, the tilesets are referenced like so

 <tileset firstgid="357" source="../tilesets/test.tsx"/>
 <tileset firstgid="362" source="../tilesets/test2.tsx"/>
 <tileset firstgid="367" source="../tilesets/test3.tsx"/> 
....

What I noticed is that when new tilesets are added to a tmx file, Tiled appends it to the end of the above list in the file. Then when trying to setup a layer with this new tileset it throws a 'Invalid Tileset reference' exception. However, if I manually edit the tmx file and put the newly referenced tileset at the top of the tileset list, then it works fine.

Basically, it seems the order in which tilesets are referenced in the tmx file causes issues with Tilengine, particularly when setting up layers.

megamarc commented 1 year ago

Hi Daniel, I can't reproduce the issue. Here I attach a sample layer using three distinct tilesets: assets.zip layer

Editing the tmx file by hand, shuffling the order of the tilesets doesn't cause any error, the layer is renderer correctly

To debug this issue I need a test asset that reproduces the problem.

Testing with Tilengine 2.14