Any assets that you add to rooms are placed on a layer. These assets can be tile maps (using tile sets), backgrounds, sprites or sequences, particle systems and instances. You can add and modify a room's layers in The Room Editor or at runtime through code.
Layers are useful for a few reasons:
You can get all layers in the current room using layer_get_all or a single layer based on the name you gave it in the Room Editor using layer_get_id.
NOTE Unlike the Room Editor, you are not limited to only certain asset types per layer, and can add assets of different types to the same layer - for example you can have a background, a tile map and an instance all on the same layer.
Each asset that you add to a layer is considered an element of that layer.
When you use The Room Editor to add assets to a room, a new element is added to that layer every time you drag an asset onto the editor canvas. There are two exceptions to this: in case of tiles the element that's added is a tile map, rather than the individual tiles that you place and also, no element is added for Paths.
To get all elements on a layer you can use the function layer_get_all_elements.
To get the underlying asset type of an element, you can use the function layer_get_element_type.
This section outlines the general functions used when working with room layers, as well as a few functions specific to working with instance layer elements:
We also have a couple of extra functions relating to targeting layers in a different room. It may be that you want to change something in a room that is not the current room, or maybe you want to generate rooms procedurally, or any number of things. To enable this we use the following functions:
What you do here is set the target room using the appropriate function and then call the layer functions are normal. These layer functions will now apply only to the target room and not the current one. When you are finished you'd call the reset function to return the code scope back to the current room again.
WARNING While targeting another room, you can use all the regular layer functions, except you cannot create instances using instance_create_layer or instance_create_depth, nor will the layer function layer_add_instance be available.
Exclusively for use with instances on layers (although the layer itself can have other elements, they will not be affected by the following functions) you have a couple of functions that can be used to deactivate or reactivate all instances:
There are no functions to get access to particle systems on a layer, but you can create them on a specific layer using the function: