How do I change backgrounds randomly?

Get help using Construct 2

Post » Sun Jul 16, 2017 4:36 pm

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.

Image
B
22
S
8
Posts: 9
Reputation: 1,470

Post » Sun Jul 16, 2017 4:56 pm

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.
B
47
S
17
G
82
Posts: 2,232
Reputation: 48,611

Post » Sun Jul 16, 2017 5:03 pm

I once did a diashow like this: http://www.gameus.de/c2/diashow.capx
Image Image Image
B
43
S
22
G
15
Posts: 383
Reputation: 12,262

Post » Sun Jul 16, 2017 6:29 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 23, 2017 12:30 am

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!

Image
B
22
S
8
Posts: 9
Reputation: 1,470


Return to How do I....?

Who is online

Users browsing this forum: DiegoSanudoDT, R0J0hound and 12 guests