How do I make Tiled export a valid JSON file?


How do I…

How do I export a Tile map JSON from Tiled?

What is the expected result

When I export the file, it should be a JSON.

What is the actual result

It never renders in the editor or in game, LDtk actually works, but tile masks doesn’t work for it. Because it’s exporting to TMJ instead of JSON, even if I change file extension it still has tmj coding.

Related screenshots

Capture (2)
As you can see, I’m on the right thing. But it only allows me to save a tmj, But I need a JSON for collision mask.

I wish the Collision masks worked for LDtk since it’s much simpler.

that’s just the file name, the file contents are still the same. Try not putting two dots in the file name.

Also you can get collisions working with LDtk, it just works differently.

Tiled just doesn’t work for me, whether there’s two dots or not.

Also, how do you get LDtk to work?

There are step by step tutorials for both tools in the documentation:

What I dont understand is though, that page (and gdevelop itself) says LDtk collisions aren’t supported.

Unless authuro meant using invisible objects for collision. I just wish LDtk had collision support.

Generally, LDtk operates in a more flexible/diy way: you can define int grid & entities layers that you can interpret as you wish in your game code.

The structure of the LDtk files is well documented, and you can also just open the file in a text editor to see how the variables are structured. You can use the “Load JSON resource to variable” extension action to load the LDtk file, and then use for example an int grid for collisions.

In your events, you can then do the collision detection by mapping the position of the player to the position on the grid, getting the value in the int grid, and handling collisions appropriately from there.

That can be a bit annoying though, alternatively you can create a collider object and, at the start of the scene, load the tilemap, loop over the int grid with for each child variable, and create a collider object at each grid position that’s got the collider placed in the int grid. It’s much worse for performance/ram usage, but it’ll be much more intuitive to work with when it’s mapped to real objects on the scene.