How do you make random backgrounds?

gotyoursgotyours Member Posts: 246
edited April 2012 in Working with GS (Mac)
hello is there away to change the background randomly? i would like to do it with a timer

Best Answers

  • patapplepatapple Posts: 873
    Accepted Answer
    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... :))
  • simo103simo103 Posts: 1,331
    edited April 2012 Accepted Answer
    @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.
  • patapplepatapple Posts: 873
    Accepted Answer
    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

  • heathccheathcc Member Posts: 113
    Another option, depending on the art, is to random shift the RGB values of your backgrounds to "colorize" them. This could enabled you to present a little more variation for the number of images you have.
  • gotyoursgotyours Member Posts: 246
    perfect that was exactly what i was looking for- 1 more question if i put them all in the same place would that use the sam RAM as calling them from off screen? Or if i do as @patapple says will that reduce the RAM load due to it calling from not on screen?- They both seem to work fine just wonder now about the Ram factor
  • gotyoursgotyours Member Posts: 246
    i think your correct, guess we shall see, thanks for the help
  • simo103simo103 Member, PRO Posts: 1,331
    tend to agree with patapple ... if multiple images then change image probably best.
  • gotyoursgotyours Member Posts: 246
    cool thanks again
Sign In or Register to comment.