layer_y

You can use this function to set the y position of the layer within the currently scoped room.

You supply the layer ID (which you get when you create the layer using layer_create) or the layer name (as a string - this will have a performance impact) and the function will move the layer the given number of pixels along the vertical axis of the room.

NOTE This function doesn't affect the position at which Instances on that layer are drawn - they remain at their (xy) position - unless those instances are controlled by a sequence (see in_sequence for more info).

 

Syntax:

layer_y(layer_id, y)

Argument Type Description
layer_id String or Layer The unique ID value of the layer to set the y position of
y Real The y position in the room to set the layer to

 

Returns:

N/A

 

Example:

var lay_id = layer_get_id("Sprites");
if layer_get_x(lay_id) != 0 || layer_get_y(lay_id) != 0
{
    layer_x(lay_id, 0);
    layer_y(lay_id, 0);
}

The above code checks the given layer position and if it is not set to (0, 0) then it is set to that position.