This function controls the alpha (transparency) of the background sprite. 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 alpha value to use. Alpha can be between 0 (fully transparent) and 1 (fully opaque) with the default alpha value for the background element being 1. Note that if the layer the background element has been assigned to is not visible - or the element itself has been made invisible - you will not see any difference with this function until the layer or element has been made visible again.


layer_background_alpha(background_element_id, alpha);


Argument Description
background_element_id The unique ID value of the background element to change
alpha The alpha for background sprite, from 0 to 1 (default is 1)




var lay_id = layer_get_id("Background_sky");
var back_id = layer_background_get_id(lay_id);
layer_background_alpha(back_id, random(1));

The above code gets the ID value of the background assigned to the layer "Background_sky" and then sets its alpha to a random value between 0 and 1.

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