How do I change backgrounds randomly?

0 favourites
  • 5 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Hi! I'm not sure how complex this issue actually is, but it's one that I've been struggling with for a while. In the below screen shot, you'll see my current background rotation setup. I change to a particular background in direct correlation to what the player's score is, or what "stage" they're on.

    My question is, how can I change the background randomly at each stage interval (or every 10 points)? The main obstacle I'm having with this is that if they are random, I have no way of identifying the previous background to fade out.

  • Each background related to a variable value, varBG=1 = sunset, varBG=2 = valley etc. Have a global variable that is a score accumulator and reset on every 10. When globalvar = 10, choose(1,2,3,4,5) however many backgrounds there are, it'll choose a random number. You could run a function with this value as a parameter, a change background function where if 1 is chosen it chooses the sunset background, 2 it sets the valley etc.

    You don't need to determine which background to fade. You can put them into a backgrounds family with a family fade behaviour. Then just before the change background function you can select family > fade.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I once did a diashow like this: http://www.gameus.de/c2/diashow.capx

  • Hey guys! Thanks a ton for all of your replies. They were all extremely helpful, and I kind of combined all of your suggestions into something that works really great!

    I have a global variable that resets every 10 points and then chooses the value of another variable at random (the BG_Picker). The rest you can see in the image below. Definitely couldn't have done it without your help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)