mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.05k stars 1.75k forks source link

Tile metadata #3959

Closed AJLProjects closed 3 months ago

AJLProjects commented 3 months ago

I would like to be able to decorate a tile with data. For a single tile I would like to specify data. For example I have a side scroller. There is a swing block. You can swing using the rope. I would like to be able to specify on the tile how long the rope should be. Or maybe I have a door tile. I would like to specify if the door is locked or not. without having a separate tile for each state locked/unlocked.

eishiya commented 3 months ago

For properties specific to an instance of tile (rather than to all instances of that tile), this can be done with Tile Objects. Tile Objects are usually the way to go for dynamic elements such as doors, collectibles, etc.

Things like ropes might be more conveniently represented with a Polyline (with two points representing start and end; more complex rope scenarios can be represented using polylines with more points), or with a Tile Object or rectangle that is stretched to the length of the rope. Represented this way, the length is visible while editing the map instead of having to be typed into a custom property. The downside is you'll need to parse this while loading the map, since it won't be a ready-made custom property.

AJLProjects commented 3 months ago

@eishiya Maybe I gave a bad example. Here is a better one. I have a chest tile. This is a grid tile because it needs to conform to the grid.

The chest can contain items. It would be nice to have a JSON popup so that I can edit the contents of the chest.

Also when you save it, you could do like a dictionary of position => json, rather then affecting the existing format of 0,0,0,1,1,2,0 ...for example

eishiya commented 3 months ago

Again, Tile Objects are the way to go there. You can make sure they're aligned to the grid by using the Snap to Grid option, and a custom String property can contain your loot list (if you click the "..." button in the string property, you'll get a pop-up multi-line string editor). If you want visual indicators of the items, that can be accomplished with additional Tile Objects, which you can link to the chest via Object references.

Objects are also stored in a more readable (but also more verbose) format than tiles.

AJLProjects commented 3 months ago

@eishiya its not correct in the purest way and is more a hacky work around. But I will close, since I can round the position to the nearest tile(integer) on my game logic.

eishiya commented 3 months ago

I should also mention: There's already an issue open for per-cell custom properties, so if you'd like that to be added, please read and possibly add to the discussion there: #31