layer_background_get_id


Description

This function can be used to retrieve the unique ID value of the background element on a layer. You supply the layer ID (which you get when you use the layer name along with layer_get_id()) and the function will return the ID value associated with the background element on the layer. Note that this function is specifically designed for use with backgrounds that have been added in the IDE, as if you add a background to a layer through code using the function layer_background_create, then it will return the unique ID for the background element added.


Syntax:

layer_background_get_id(layer_id)


Arguments:

Argument Description
layer_id The unique ID value of the layer to target


Returns:

Background element ID value (Real)


Example:

var lay_id = layer_get_id("Background_trees");
var back_id = layer_background_get_id(lay_id);
layer_background_sprite(back_id, bck_Trees_Winter);

The above code will get the layer ID for the layer named "Background_trees" and then use that to get the ID of the background element on that layer. This ID is then used to change the element sprite.


Back: Background Layer Functions
next: layer_background_exists
© Copyright YoYo Games Ltd. 2018 All Rights Reserved