Update Tiled crate and related example to 0.11.0#425
Conversation
Bushstar
commented
May 6, 2023
- Updated the Tiled crate to 0.11.0.
- Creates BytesResourceReader and implemented the ResourceReader trait for the new tiled::Loader behaviour.
- Renames TileLayer to Tiles.
|
There's another (abandoned?) implementation here: #405 but I prefer yours because of the limited scope and error handling. The other PR goes through the effort of bypassing Tiled's cache with a |
|
Note that the the cache is not a new addition to Loader and defaulted to DefaultResourceCache before, this PR does not affect cache behaviour. You can review the changes to Tiled here where a Reader was added to Loader in the link below. I'd be inclined to leave this as is and leave users to explicitly change this behaviour if required. |
|
Makes sense to me. |
|
When and if this PR gets merged I'd like to create a new PR based on the changes in this one to support TMX maps with TSX tilesets. The changes are shown in the commit below. The problem with Bevy and TSX tile maps seems to be that when rs-tiled tries to load the TMX map and comes across the TSX file it will try to read it from the bytes again and will then error as those bytes are the same TMX file just read. In the above commit I've updated the code to check the Path, if it includes a .tsx extension then it should try and load from disk using the same path provided by Bevy via the LoadContext argument. Spoke to the rs-tiled developer about this and it sounds like at some point it will be updated to allow loading dependencies separately from their parents, but until then we need something like the above commit. That conversation can be found here where I initially asked if the error I encountered was a bug. |