layer_set_visible


Description

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.


Syntax:

layer_set_visible(layer_id, visible)


Arguments:

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)


Returns:

N/A


Example:

var lay_id = layer_get_id("Instances");
if layer_get_visible(lay_id)
   {
   layer_set_visible(lay_id, false);
   }
else
   {
   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.


Back: General Layer Functions
next: layer_get_visible
© Copyright YoYo Games Ltd. 2018 All Rights Reserved