Using this function you can change the tile set resource assigned to a given tilemap element on a layer. You give the tilemap element ID (which you get when you create a tilemap element using layer_tilemap_create() or when you use the function layer_tilemap_get_id()), and then supply a tile set index and the tilemap will be given the new sprite.
tilemap_tileset(tilemap_element_id, tileset_index)
Argument | Description |
---|---|
tilemap_element_id | The unique ID value of the tilemap element to change |
tileset_index | The new tile set index to use |
N/A
var lay_id = layer_get_id("Tiles_trees");
var tile_id = layer_tilemap_get_id(lay_id);
if tilemap_get_tileset(tile_id) != ts_Nighttime
{
tilemap_tileset(tile_id, ts_Nighttime);
}
The above code checks the current tile set assigned to the timemap on the layer "Tiles_trees" and if it is not "ts_Nighttime" then that tile set is assigned to the tilemap.