Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TiledMap can be loaded only in xml format and not json. #7291

Open
patton73 opened this issue Dec 4, 2023 · 8 comments
Open

TiledMap can be loaded only in xml format and not json. #7291

patton73 opened this issue Dec 4, 2023 · 8 comments

Comments

@patton73
Copy link

patton73 commented Dec 4, 2023

Basically this is a request for new features.

I would like to have the chance to load a map in json (.tmj) format from TILED. Right now only .tmx formats are loaded.
More i would like to have in the loader also a method to load a defined Tileset file (both formats as well) directly into a TiledMapTileSet.

Thanks a lot for your efforts.
Keep up the incredible good work.

@Kevin-Garnier
Copy link

Hi, I'll try to add it.

@Kevin-Garnier
Copy link

Hi @patton73, I'm not sure to fully undestand what you mean by having in the loader a method to load a defined Tileset file directly into a TiledMapTileSet. Isn’t it already the case with the TmxMapLoader, which loads a map with the associated tilesets from the given file?

@patton73
Copy link
Author

Hi @Kevin-Garnier thanks for the question.
Basically is not the same. Right now you can only load a predefined Map (made with Tiled). So you can load the entire map with tilesets included. But what if i would like to generate a random map using those tilesets?
Right now you cannot do it. You can only load a complete map but not a complete tileset.

According to me this is a cool upgrade to the library.
At least make those methods public, so you can use them to load a fully functional tileset to generate a random map.

Thanks anyway for your effort.
For any question please ask.

@mgsx-dev
Copy link
Contributor

But what if i would like to generate a random map using those tilesets? Right now you cannot do it.

@patton73 right now you can load an empty map references those tilesets and use them to generate your maps : map.getTileSets().getTileSet("awesome-tileset"); which is an OK workaround IMHO.

About JSON format, i'm not sure what the benefits using this format but assuming you get a tilemap/tileset from someone else, you could re-export them as XML from Tiled.

I can understand that it could be nice to have full support at some point but those are easily workaround-able until then.

@patton73
Copy link
Author

patton73 commented Apr 18, 2024

@mgsx-dev
Having a public method that permits you to load a Tileset file (and not and empty map with titlesets in it) to me is really important and prioritary and will be a lot cleaner in terms of assets organizations. Since in Tiled i can have tileset files outside the map, and use them to generate a fixed map. But i could use them also to generate random map. And more is relatively easy to implement. The tileset basically defines a graphical "scenario". The map defines the meta scenario. So i could make Scenario packages based on tilesets. It really affects the asset's organization.

I agree with you that loading json format is a good surplus but not a priority.

@mgsx-dev
Copy link
Contributor

Since in Tiled i can have tileset files outside the map.

@patton73 actually you can load TMX maps with libGDX which has separated TSX files, in this case tilesets are not embeded into the TMX map, it only references them. So your code doesn't need to know if tilesets are embeded or referenced by the tilemap, which could be a plus in term of assets organization for some people. That said, i can understand it could be more handy for some people to directly load TSX files, no doubt.

@Kevin-Garnier
Copy link

I've already done the json format on my fork, I can do that too

@Quillraven
Copy link
Contributor

Quillraven commented May 11, 2024

@Kevin-Garnier : I saw you opened a PR with some Tiled enhancements which is great.

Can you please also include a fix that the loader does not crash with properties of type file? It crashes in a castProperty method of the loader because it does not support that type.

Imo it should not crash and simply load it as a string (no cast necessary).

Also, imo text objects are also not loaded correctly. They don't contain any of the text properties that Tiled stores.

If you have time and motivation it would be great if you can add the support for this as well ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants