I think I have a very peculiar use case, and I’m wondering if I’m using the right approach with Tiled (I’m pretty new using this tool).
Basically we use an external tool to draw game maps that are exported as .PNG files. However, from a logic perspective, the game expects maps to be “tiled”, and each tile is a 24x24 pixel cell. Our requirement is that it must be possible to set individual properties to each tile on the map (so property values are tied to their position on the map, not to the tile itself).
So far I’ve used the following approach
Load the PNG file in an Image layer
Have a tileset composed of just one tile (to be used as placeholder)
Create an object layer, select “Snap To grid” and paste the tile as object in every map cell. This totally satisfies our requirement, since we can set individual properties to the objects. We then have a post processing python script that loops through the objects and create data in a format our game can read
The reason I’m writing here is that it seems an overkill to have objects as placeholders for properties, particularly because our post processing script is basically just converting the object layer in an array of properties anyway.
I’ve tried using the tile layer, but it seems I can attach properties only to the tile itself, and I can’t change the value once it has been place on the map.
So, is there any other way to adhere to my requirements without using the object layer? I’m fine if I have to, just wondering if I’m missing something obvious
I am curious about this as well, but as far as I can tell you can set properties for the tile (abstract) but not the placed tile (instance) because the placed tile just corresponds to an ID, and does not contain additional information. The thing that contains additional info (besides the abstract tile) is the layer itself or as you also found, the object layer. I can’t think of a way you’d be able to add cell-level-info well because the map wold be pretty big if every tile also possessed a lot of meta info, and most tiles wouldn’t.
Since your implementation is fully abstracted from editing - even though its overkill to use Objects, that shouldn’t affect you negatively since you’re not loading the actual map from tiled, but something thats undergone processing (the .png) (am I understanding that right?).
As I said, you can certainly make another layer and add info to that. Lets say you had bricks and you wanted some to be breakable, others not - you could either make 2 tiles that look identical, but one has a breakable prop, or you could make 2 layers “breakable and nonbreakable” and use the same tile. What you cant do is go tile-by-tile on the same layer and set arbitrary props, but as I said that makes sence…because your level would be very very big. You’d replicate ‘breakable’ on every cell. What was once an array of numbers is now way way bigger, so this is a major footgun to most mapmakers.
Thanks for your thoughts.
You are correct about the overkill not being a problem: the python script is actually pretty fast so even in the worst case scenario, where each 24x24 square on the map has an object associated with it, this doesn’t affect the game at all, since it works with postprocessed data.
The trick you suggest later however, can’t be used because I need to encode an integer property that can have 128 possibile values and so it’s not something I can encode with a boolean.
I’ve already started with the objects-snapped-grid approach, and so far I can’t see any drawbacks, really. I was just wondering if there was something obvious I was missing
I’m just wondering, if you couldn’t instead just create a tileset with 128 tiles, either with changing color or actually labelled with a number each? That way mapping should be quite comfortable since you can at a glance see the distribution of values as well as quickly copy/paste/modify those values. The only thing you loose is the ability to type in the value.
That said, I have considered to add support for generic “data” layers, where you would for example be able to associate a number, string or color with each cell on the layer. Maybe one day it’ll be supported.