Tiled map editor export to Defold (SOLVED-ish)

Presumably because there is some kind of rotation meta data in tiled? But Defold tiles don’t support rotation of tiles does it? I don’t remember… it’s strange that the editor picks up on it but not the engine.

You can use animations to make multiple rotations without adding the rotation images themselves.

Not rotation, but mirrored tiles. The .collection export takes this into account, and uses it for rotation. It works everywhere aside from in game.

How do you mean?

I’m mistaken, tile sources support animations, but not tile maps. Animation support was requested years ago. :slight_smile:

There isn’t a way in the builtin editor to flip tiles horizontally and vertically either but maybe it was planned but not implemented in the engine?

I was curious about that too. Turns out you can flip tiles via tilemap.set_tile(), but it’s weird that you can’t do that in the editor.

We have this on our list of things we really should support soon. We’ll keep you updated on this!

3 Likes

Now it seems even more strange that the data works in the editor but not in the engine, but if you manually set the tile in the engine it works?

Investigation time!

Just like what @totebo found, manually flipping the tiles by editing the tilemap file makes the tiles appear flipped in the Defold editor, but not in-game. Flipping tiles via tilemap.set_tile() works perfectly fine, but of course it only shows up in-game. If someone really wanted to, they could probably make an editor script to scan tilemap files and output a table containing coordinates of tiles to be flipped by a script.

Screenshots

Left: unflipped tiles | Right: Horizontally flipped tiles
-----------------------------------

Manually flipped tiles in editor:
h-flipped_in_editor

Manually flipped tiles in game:
h-flipped_in_game

Tiles flipped via script in game:
h-flipped_in_script

1 Like

We will fix this in 1.2.169. Adding tile flipping support in the editor will have to come later.

4 Likes

Another question in regards to the .collection export. How would you practically use the exported collection in Defold?

My method feels a bit clunky: Create the collection with a collection factory, then, to get collisions, create a game object with a matching collision object inside. Is this the best way of doing it?

Yeah, this feels a bit clunky to be honest. I haven’t tried the exporter myself.

The fix in 1.2.169 doesn’t seem to work for me. I made a tiny repro project, including the Tiled source files, which might help figure it out: RotatedTiles.zip (29.1 KB)

Tiled:

Editor:

Engine:

Yeah, there was a problem with the first beta. I’ve verified that it is fixed with the latest beta. Sorry about that!

1 Like

Let me respond in the shape of an in game Tilemap:

3 Likes

Looks like I jumped the gun on this one in all the excitement!

Coming to actually implement rotated tiles, it’ turns out that flipped tiles work (180 degrees), but rotated tiles (90 degrees) do not. The reason the above example appeared to work was because I only used corner tiles. This is how it looks with edge tiles:

Tiled:
20

Defold:

Minimal example: RotatedTiles.zip (47.9 KB)

Is there any way Defold could support 90 degree rotation? Or (please let it be so) have I missed something?

It is currently not supported. Only flipping of tiles.

1 Like

Alrighty then. At least flipping works on corners, so still good!

And sides too I guess?

Edges work in two of the four directions, so for those one extra tile is needed to provide the 90 degree turn.

Sure, but it’s still a save. Which was my point.

Yep, very much so.