How do I select random music?

Get help using Construct 2

Post » Wed Mar 16, 2016 12:45 pm

If I had 5 songs, how would a play them randomly, so if one finished, another random one would play, not the previous one though.
I don't think I could ever stab someone, I mean, let's be honest. I can barely get the straw into a Capri Sun.
B
26
S
10
G
7
Posts: 91
Reputation: 6,420

Post » Wed Mar 16, 2016 1:56 pm

The simplest method I can think of is just to create a little counter using a global variable. Call is "Track" or whatever.

Now you create a function that when called plays the track according to the number of the counter variable.

Track = 1 -> Play X track
Track = 2 -> Play Y track

You have the "on finished playing" condition, when the music finishes it either randomises the Track variable again or adds 1 to it etc and then calls the function again to play.
ImageImage
B
123
S
23
G
7
Posts: 1,071
Reputation: 13,091

Post » Wed Mar 16, 2016 5:29 pm

Thx that helps
I don't think I could ever stab someone, I mean, let's be honest. I can barely get the straw into a Capri Sun.
B
26
S
10
G
7
Posts: 91
Reputation: 6,420


Return to How do I....?

Who is online

Users browsing this forum: maranpis and 25 guests