I’m developing a tile set that is very much a WIP, and I’m constantly changing things around. I have a test map that I made, but I don’t want to recreate it everytime I switch the position of tiles around.
Obviously this will be even worse later when I’ll have made a few maps and still need to switch things around. May be a weird use case but this is my current workflow for this project.
Is it possible to move a tile in an atlas without ruining the map?
You can set tiles in a tilemap programatically with set_cell()
, so you could write some code to generate the tilemap from a template. If you also have a map of tile types to tile atlas coordinates (say, an array of Vector2i
values), you could march over the template:
func generate_tilemap(src: Array, map: TileMapLayer, tiles: Array, size: Vector2i):
for y in size.y:
var y_offset = y * size.x # Calculate this once per loop.
for x in size.x:
var pos = Vector2i(x, y) # Coords in the tilemap.
var src_tile = src[x + y_offset] # Source tile index.
var tile = tiles[src_tile] # Tile atlas coords.
map.set_cell(pos, 0, tile)
Thanks. I will explore this.