Tiled formula for converting isometric coords to tile row and column

While working on an isometric map, Tiled’s Object layer’s Insert Point tool saves an X and Y property (100/90 that refers to the isometric plane). I have also noticed that Tiled also shows in the bottom label the corresponding tile column and row (4, 3) as well as the canvas x and y properties (2409, 94). When I save the isometric map, I open the file and look into the object layer and I see that for every object only the isometric X and Y coords are saved. How can I configure Tiled to save the tile’s column and row as well as the canvas X and Y properties for every object in the Object layer?

If this is not possible, could you please provide a formula for converting the X, Y in the object layer to the corresponding map’s tile column/row and canvas X/Y?

Thanks

I don’t think you can export the tile-wise coordinates.

For non-staggered isometric maps, the X/Y coordinates seem to be the grid coordinates multiplied by the tile height, so to get the grid coordinates back is simple: Tx = X / tileHeight, Ty = Y / tileHeight. Note that Tx and Ty might not be integers if the object’s placement isn’t aligned to the tile grid. Tiled seems to take tileHeight as the length of the side of each tile and that’s why that’s the number used in both the X and Y calculations. There’s probably a good reason for it, but I haven’t messed with isometric maps enough to know why.

2 Likes

Thank you. You have given me a north.

1 Like

I’m not sure there was a good reason for it. It’s a bit of a strange compromise between just using floating point tile coordinates for object position vs. pixel coordinates as is done on orthogonal maps.

The assumption was that generally isometric tiles are really a projected square. As such it would have made no sense to divide x by tile width and y by tile height, as done for orthogonal maps when converting pixel to tile coordinates.

But this is frequently a source of confusion, so in hindsight I think it may have been better to use tile coordinates for objects on isometric maps.

1 Like