TheBoneJarmer / TiledCS

TiledCS is a dotnet library for loading Tiled tilesets and maps
MIT License
139 stars 51 forks source link

Issues with objects that belong to tiles #88

Closed Frankfires closed 2 years ago

Frankfires commented 2 years ago

Retrieving Object.type from a tile's objects returns a blank string, I am able to retrieve x/y/width/height which works out for points and rectangles because you can identify the difference between them by checking if width/height is 0. For ellipses and polygons though I'm afraid it's impossible to check if the object is one of those two

image image image image

Also, tiles without any objects aren't included in TiledTileSets, adding at least an object to each tile will resolve this error. Don't know if this intentional or not, but I think tiles without objects should still be included in TiledTileSets for easing the process of making tiles without collision

image image image image

Frankfires commented 2 years ago

UPDATE: it appears that I've forgot to subtract my TileID variable by 1 like the half brain celled sack of flesh I am, the out of bounds exception is my fault 🤡

TheBoneJarmer commented 2 years ago

Hey @Frankfires

Concerning your issue with the type field. This works as intended. The type field is empty I believe because its default is a rectangle. When you use a tile as object the type field is empty too but the gid field is set. And in case of a point, polygon or ellipse, the fields polygon, point and ellipse are set respectively. To be honest I don't know for certain when it does get filled. But Tiled was designed this way so I just respect it. But when I talk to Björn I will ask him if he could elaborate on it further.

As for the issue with the TiledTileset.Tiles property, Tiled only saves tiles which contains data like animations or properties. So they only serve as a data container for a specific tile rather than the tile itself. This is how Tiled was designed and thus TiledCS only loads what it can find. I could fill up the array with tiles that were not defined in the tileset but than the whole array could become really big and I am not certain that is desirable for those with many tilesets.

I hope you understand and if you have questions, shoot!

With kind regards, TheBoneJarmer

Frankfires commented 2 years ago

Aha I got it makes sense now ty! 👍