You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like you have been doing a lot of work on this library. I was doing a similar thing last year and had a few insights while implementing.
I started out, like you, with a separate types of ObjectGroups, ImageLayers, and TileLayers. Unfortunately, if you do that, it is impossible to reproduce Tiled maps correctly when drawing, because you lose the layer order between the different types. In Tiled, you can put any layer type in any order and that should be how they are drawn. The draw function now will right now iterate through all the tile layers, then all the image layers, (then presumably objectgroups and groups later). In tiled however you can intersperse all layer types in any order.
While I was struggling with this problem I realized that actually ObjectGroups, ImageLayers, TileLayers, and Groups can all be parsed into a single struct type which can then identify the type using the xml.Name.
Hi bcvery1,
It looks like you have been doing a lot of work on this library. I was doing a similar thing last year and had a few insights while implementing.
I started out, like you, with a separate types of ObjectGroups, ImageLayers, and TileLayers. Unfortunately, if you do that, it is impossible to reproduce Tiled maps correctly when drawing, because you lose the layer order between the different types. In Tiled, you can put any layer type in any order and that should be how they are drawn. The draw function now will right now iterate through all the tile layers, then all the image layers, (then presumably objectgroups and groups later). In tiled however you can intersperse all layer types in any order.
While I was struggling with this problem I realized that actually ObjectGroups, ImageLayers, TileLayers, and Groups can all be parsed into a single struct type which can then identify the type using the xml.Name.
You can see my solution here: https://github.com/elliotmr/tmx/blob/master/tmx.go#L92
There is also a pixel integration example library here:
https://github.com/elliotmr/tmx/tree/master/pixeltmx
Since I don't have time to work on my library, feel free to use any concepts from it in yours.
The text was updated successfully, but these errors were encountered: