Where to turn "on" and "off"? is it possible to randomaze?easier thing is to make them 6 different backgrounds and then turn off and on which one is visible.
But the background is not an object, so where to wirte the code?i would start with these two terms..
image_index = random(n)
// assuming all the backgrounds are already set to visible false
randomize();
var i; // temp var to decide
i = irandom(6);
switch(i)
{
case 0:
var lay_id = layer_get_id("BG1");
break;
case 1:
var lay_id = layer_get_id("BG2");
break;
case 2:
var lay_id = layer_get_id("BG3");
break;
case 3:
var lay_id = layer_get_id("BG4");
break;
case 4:
var lay_id = layer_get_id("BG5");
break;
case 5:
var lay_id = layer_get_id("BG6");
break;
}
layer_set_visible(lay_id, true);
Didn't work niether !Did you assign a sprite to a background layer (called "Background" in my example) already? The background element needs to already be in place.
I could make this work:yes, you just change instances to the name of the background you want to hide and it then you basically to an irandom then do a switch statement or an if block that makes one visible and the rest invisible.
EDIT: here you go assuming all the layers are set to not visible. I will leave you some logic work if you want to swap them around during the game.
Edit fixed the code a bit. What i get from coding from the hip i guess.GML:// assuming all the backgrounds are already set to visible false randomize(); var i; // temp var to decide i = irandom(6); switch(i) { case 0: var lay_id = layer_get_id("BG1"); break; case 1: var lay_id = layer_get_id("BG2"); break; case 2: var lay_id = layer_get_id("BG3"); break; case 3: var lay_id = layer_get_id("BG4"); break; case 4: var lay_id = layer_get_id("BG5"); break; case 5: var lay_id = layer_get_id("BG6"); break; } layer_set_visible(lay_id, true);