2d_warrior
Member
How do I test whether a layer is a tile layer, or not, in code without knowing beforehand?
So there's no way to get only the layers (specifically id or name) in the room editor that are tile layers (have the 4 diamonds icon)? The room editor seems to give the impression that they are layers, with the different layer types. Do I have to name tile layers differently to find them in the Room Start event using layer_get_all() and step though all existing layers till I find the layers with "my_tiles" or some suffix I add to the name?There's no way to get the layer type as a layer need not be limited to a single asset type dynamically. For instance, you can put a tilemap and a background on the same layer, so GM won't know what to return. You can, however, get the ID of an element from the layer and use layer_get_element_type to know what kind of elements are placed on the layer.
var a = layer_get_all();
for (var i = array_length_1d(a) - 1; i > -1; i--) {
var prefix = string_copy(layer_get_name(a[i]), 1, 4);
if (prefix == "tile") {
ds_list_add(tile_layers, a[i]);
}
}