Closed ForeverZer0 closed 4 years ago
Hi,
The datastructure in libTMX reflects the TMX file format, so you can navigate through it just like you'd navigate the XML tree. The map's height and width is defined once at root level (
I don't know ruby so I can't really help you. Sorry for the late reply.
Currently working on a 2D game API, a Ruby C extension. I am exposing each component of a map to Ruby via C, where each type in this library has its own Ruby type. All of this is pretty straightforward with the exception of wrapping a
tmx_layer
with a type ofL_LAYER
. Thecontent
union for this type simply uses a pointer to an array of integers, without any clear indication at this particular point how many GIDs are in the array.This information can be reached higher up the chain, but does not translate well into wrapping into an object-oriented type. The only solution I have found is setting the tile count to the
user_data
field when I am enumerating the map's layers.Hopefully this can help clarify:
My current solution, though not very elegant:
This allows for the layer to hold a value to know how many tiles are in the map the layer belongs to, but not ideal. This isn't much of a problem in the C side during rendering etc, but feels very clumsy in my specific scenario.