Randomizing Audio (Background/Objects)

Get help using Construct 2

Post » Wed May 29, 2013 5:25 pm

New question! I want to randomize my background audio while the game is running. IE When one track finishes another track starts, randomly chosen from a list.

I also want to randomize the audio when an object is destroyed!

Now, the only thing I am thinking of is using families for this? Is that even possible? (I do have a personal license)
MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

Post » Wed May 29, 2013 5:41 pm

use choose
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Wed May 29, 2013 5:43 pm

You could just use the same tag for all of your backing audio, then when any audio with that tag ends, have it begin a new song selected at random.

ie.
On audio ended, tag = "bgmusic"
        if random(0,20) >= 10
              play audio "track1" tag="bgmusic"
        else
              play audio "track2" tag="bgmusic"

then you can just keep adding to the list for each audio track that you have.
B
21
S
8
G
5
Posts: 89
Reputation: 6,017

Post » Wed May 29, 2013 5:56 pm

[QUOTE=California] use choose[/QUOTE]

So something like:

MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

Post » Wed May 29, 2013 6:19 pm

use play by name event, then in the name set it to choose("bgm1","bgm2","bgm3")
B
8
S
2
Posts: 48
Reputation: 1,098

Post » Wed May 29, 2013 6:19 pm

I think California was trying to say you could do something like this:

Play by Name
-choose("BGM1","BGM2")

Your method also works though. :D
B
13
S
4
Posts: 117
Reputation: 2,242

Post » Wed May 29, 2013 7:57 pm

@stomphoof Yep, just set the tag in each of your play audio actions. Then make your condition check to see if that tag has stopped playing.

You might want to make the "test >= 0" when into an else though, because right now it will always play BGM1 since test is always greater than or equal to 0.
B
21
S
8
G
5
Posts: 89
Reputation: 6,017

Post » Fri May 31, 2013 8:04 pm

[QUOTE=rabidsheep] @stomphoof Yep, just set the tag in each of your play audio actions. Then make your condition check to see if that tag has stopped playing.

You might want to make the "test >= 0" when into an else though, because right now it will always play BGM1 since test is always greater than or equal to 0.[/QUOTE]

That was more about the actual events then the conditions of em. I was just stuffing numbers in places haha
MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862


Return to How do I....?

Who is online

Users browsing this forum: banquetburger and 47 guests