Define tilemap size in properties (DEF-1779)

Currently (afaik) to have a Defold tilemap which you intend to import other data such as Tiled’s into you must draw the bounds at the very least for the size you want. It would be nicer to be able to set it in the properties, or also be able to set or change it in script.

6 Likes

Good idea. Created a ticket for this: DEF-1779

2 Likes

Thanks.
Stumbled apon this several times as well. As soon as I draw the “bounds” I forgot to report it. :slight_smile:

3 Likes

This is a very good idea!

1 Like

Meanwhile, a workaround (if you know the maximum map size beforehand, but do not want to draw the border).

Open your .tilemap file and add two cells there, for bottom left and top right corners of the map. For example, this defines a 1000x1000 map:

tile_set: "/main/main.tilesource"
layers {
  id: "ground"
  z: 0.0
  is_visible: 1
  cell {
    x: 0
    y: 0
    tile: 2
    h_flip: 0
    v_flip: 0
  }
  cell {
    x: 999
    y: 999
    tile: 2
    h_flip: 0
    v_flip: 0
  }
}
material: "/builtins/materials/tile_map.material"
blend_mode: BLEND_MODE_ALPHA
2 Likes

Hey all,

Just signed up with Defold yesterday and I’m liking what I see so far (editor 2.0 seems excellent by the way!)… so many thanks to everyone involved :wink:

Quick post here to say that I just spent an hour as a new user struggling against the tilemap bounds issue detailed in this thread. I was trying to setup my map through code but was consistently getting messages telling me my ‘supplied tile was out of range’… which left me a bit confused.

Eventually figured it out through tilemap.get_bounds and experimenting with placing tiles on the map in the editor and then seeing what I could set through code (ended up placing bottom-left and top-right tiles in the editor to define the bounds).

Came to the forum to post about the possibility of a ‘tilemap.set_bounds’ function and found this thread so I thought I’d just lend support to this feature request. As a new user this would have saved me a fair amount of confusion… also, it seems like it would be nice to control the tilemap size when building my maps in code rather than having a huge one size fits all tilemap for even small levels I produce. I imagine this might help with memory usage … though as a complete novice with defold I guess this might not really be an issue(?)

Anyway, thanks again for the engine :slight_smile:

5 Likes

I agree with you that it feels kind of awkward to have to predefine the bounds of the thermal the way you did. We should document this better @sicher. A set_bounds function or a width and height property on the tilemap feels better. The thing is that Defold allocates everything up front and from that perspective the current system with predefined bounds makes sense.

2 Likes

Fair enough then, given that the bounds need to be predefined i think width and height properties on the tilemap in the editor would work well. It would definitely need to be clearly documented that they couldn’t be adjusted at runtime though (perhaps in the API ref for ‘tilemap.get_bounds’ function).
Thanks :slight_smile:

3 Likes