This function can be used to set the image index of the background sprite which has multiple sub-images. You give the background element ID (which you get when you create a background element using layer_background_create() or when you use the function layer_background_get_id()), and then set the image index to use. If you set a value outside of the range of sub-images, then the image index will loop around.


layer_background_index(background_element_id, image_index);


Argument Description
background_element_id The unique ID value of the background element to change
index The image index to use for the background




var lay_id = layer_get_id("Background_trees");
var back_id = layer_background_get_id(lay_id);
layer_background_index(back_id, 1);

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 image index.

Back: Background Layer Functions
next: layer_background_speed
© Copyright YoYo Games Ltd. 2019 All Rights Reserved