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
71
S
24
G
11
Posts: 452
Reputation: 12,343

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
395
S
231
G
88
Posts: 24,367
Reputation: 193,694

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
289
S
112
G
94
Posts: 7,333
Reputation: 69,287

Post » Fri Aug 24, 2012 12:10 am

Thank you! Sorry I must have missed that!
B
71
S
24
G
11
Posts: 452
Reputation: 12,343


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests