Play random sound effect

Discussion and feedback on Construct 2

Post » Thu Aug 23, 2012 7:44 pm

I tried searching and looked at the manual and couldn't find anything so I'll go ahead and post. Basically I want to play one of 3 sound effects every second. It needs to be randomly selected. How do I do this?
B
66
S
23
G
11
Posts: 452
Reputation: 12,077

Post » Thu Aug 23, 2012 8:02 pm

Use the 'Play (by name)' action in the Audio object and use an expression like this:

choose("sound1", "sound2", "sound3")

choose() picks one of the parameters at random, so it will pick a random sound to play.
Scirra Founder
B
383
S
224
G
86
Posts: 24,106
Reputation: 190,410

Post » Thu Aug 23, 2012 11:58 pm

You might also want to check the How do I FAQ

In the section "Audio" :
[quote]Play a random sound - LINK[/quote]
Which should contain some other examples capx.

New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
276
S
103
G
84
Posts: 7,288
Reputation: 83,091

Post » Fri Aug 24, 2012 12:10 am

Thank you! Sorry I must have missed that!
B
66
S
23
G
11
Posts: 452
Reputation: 12,077


Return to Construct 2 General

Who is online

Users browsing this forum: Ticket Games and 8 guests