Closed guifes closed 4 years ago
I'm not very familiar with the details of Tiled's map format, got any more details about this? Or are you working on a PR anyway? :)
Tiled layers are loaded into the TiledMap.layers
property, an array of TiledLayer
s.
Grouped layers in Tiled allows nesting layers into groups (visually represented in a folder hierarchy). Currently TiledMap.layers
only loads the direct layers from Tiled and not the nested layers from groups.
I see two solutions:
Recursively load all layers of a grouped layer directly into TiledMap.layers
.
TiledMap.layers
would remain a single dimension Array<TiledLayer>
.
Recursively load all layers of a grouped layer nested into TiledMap.layers
.
TiledMap.layers
would become a multiple dimension array.
I think the first solution is more straightforward, and layerParent
/ layerChild
properties could be added to preserve the hierarchy. Thoughts? :)
I've have created a PR https://github.com/HaxeFlixel/flixel-addons/issues/319.
I made it trying to change as little as I could from the original code base. Tiled kinda treats groups as layers so I created a TiledGroupLayer, added another type to TiledLayers Type named GROUP, and when loading layers I check for group layer and add all it's internal layers recursively. I forwarded the noLoadHash to TiledGroupLayer so that it could check for "no load layers" as well.
I went with "2" (@elliocheerio ) because that produces a result more close to what I would expect from the structure of the tiled xml. But I'm not against making nested layers redundantly accessible from TileMap's layers and layerMap directly.
The PR covers my needs, but feel free to edit and add anything that might be missing.
That's about it