With this function you can toggle the visibility of a layer. When a layer is invisible, nothing that is assigned to the layer will be drawn, and if any instances are assigned to the layer then they will not even run their draw event (much the same as if you set the instance variable visible to false). Note that any instances that are already flagged as invisible will not be flagged as visible if the layer they are on is set to visible, as these are two independent settings, although their behaviour is the same.


layer_set_visible(layer_id, visible)

Argument Description
layer_id The unique ID value of the layer to target (or the layer name as a string)
visible Whether the layer should be visible (true) or not (false)




var lay_id = layer_get_id("Instances");
if layer_get_visible(lay_id)
   layer_set_visible(lay_id, false);
   layer_set_visible(lay_id, true);

The above code gets the ID value for the layer named "Instances" in the room editor, then uses the ID to check if the layer is visible or not, toggling the layer visibility depending on the returned value.