sound effects

Non-platform specific questions.

sound effects

Postby bkelynch » Wed May 14, 2008 11:49 pm

How do you play a random sound from a set of sounds when an actor gets hit?
bkelynch
 
Posts: 73
Joined: Sun Dec 04, 2005 7:48 pm
Score: 0 Give a positive score

Re: sound effects

Postby DST » Thu May 15, 2008 2:10 am

make an integer variable. here i've made one called 'soundchoose'.
an actor>collision:
Code: Select all
soundchoose = random(3);
switch (soundchoose){
case 0:
PlaySound("data/sound.wav", 1, 1, 1);
break;
case 1:
PlaySound("data/sound2.wav", 1, 1, 1);
break:
case 2:
PlaySound("data/sound3.wav", 1, 1, 1);
break;
}
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron