How do you make random backgrounds?
hello is there away to change the background randomly? i would like to do it with a timer
Best Answers
-
patapple Posts: 873
1)create a new integer attribute "background"
2)create a new timer. every 10 seconds change attribute "background" to (random 1,5) (from 1 to how many backgrounds do you have)
3) create a background image a create a new rule:- When attribute "background" is = 1 ==> change image to background 1
- When attribute "background" is = 2 ==> change image to background 2
- When attribute "background" is = 3 ==> change image to background 3
- When attribute "background" is = 4 ==> change image to background 4
- When attribute "background" is = 5 ==> change image to background 5
hope that helps...
) -
simo103 Posts: 1,331
@gotyours ... I would consider having all the backgrounds in place (physics moveable off to save resources) and their Alpha set to 0. Then using a timer trigger the self alpha to 1 on them in the interval and order you want, setting the Alpha back to 0 on the one that is not presently showing. Note: a full screen image size can effect RAM usage so having lots can eat up your available RAM. Make sure they are highly optimized and also consider changing one images color attributes to create different backgrounds using the same image or using other smaller images to create the change effect you want. I had a mostly plain background that I changed the colors on and a partly transparent star burst like image that I had rotating in front of it and that gave the appearance of numerous backgrounds. -
patapple Posts: 873
I think my method can reduce the ram, because it load an image only when the attribute corresponds. If you put all the 5 images on the same scene, it could took a little more.
Answers