mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Rendering specification in case map's tile size does not match tileset's tile size #3848

jube posted onGitHub

Is your feature request related to a problem? Please describe.

I have been writing a renderer for TMX maps, and I have a staggered map that has a tileset that does not have the same tile size as the map's tile size in the XML. In this case, I don't really known what to do. I have been patching my code in various ways but I have never been satisfied with the patches. They have to work for all the layouts, not just staggered. If necessary, I can provide a simple example.

Describe the solution you'd like

Is it possible to specify the expected behaviour in case map's tile size does not match tileset's tile size for all the layouts?

Describe alternatives you've considered

I have tried to understand the code in Tiled, but I did not managed to find the lines where this is handled.


The behaviour is already in the TMX documentation, in the section on <map>:

The tilewidth and tileheight properties determine the general grid size of the map. The individual tiles may have different sizes. Larger tiles will extend at the top and right (anchored to the bottom left).

So as you can see, the tile size doesn't actually matter and all the map orientation does is change the screen-space position of the tiles. Once you have the position, you just render the tile at whatever size, anchored to the bottom left of the cell('s bounding box). Prior to Tiled 1.9, this was always just the tile's native size, but as of 1.9, the Tileset has a "Tile Render Size" property which can be set from the default "tile" (native tile size) to "grid", in which case the tile should be scaled to fit the cell size. In case of "grid", you should check the "Fill Mode" to determine whether the scaling should maintain aspect ratio or not.

I've previously written in far too much detail on calculating the screen-space positions for different map orientations in my Tip Sheet, perhaps you'll find it useful.

It would be nice if the docs made it explicit that the bottom-left thing applies to smaller tiles as well, and linked to the tile render size specification since that determines the tile size now.

posted by eishiya over 1 year ago

Thanks for your detailed response @eishiya! Your tip sheet is excellent. I have not read it entirely yet but I will.

posted by jube over 1 year ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests