Page 1 of 1

Sounds

PostPosted: Sat Mar 25, 2006 7:39 pm
by duracel92
I'm not very good at scripting or code or even the simple codes that you get...

I have a sound playing and when it goes out of view I want it to stop. I know I need to use the stop sound feature but I doesn't work, Generally giving the error "undeclared identifier (name of sound)".. How can I fix this?

PostPosted: Sat Mar 25, 2006 11:19 pm
by The achievement
i would suggest making 2 actors, make one actor just floating in the air, and if you hit it, it plays the sound. then make another actor and make a collision and all that lovely stuff and use script editor and use a event diasable action.

If you have any problems keep on asking! :D

PostPosted: Sat Mar 25, 2006 11:38 pm
by duracel92
its ok.. lol its the script to stop the sound is what i need...

PostPosted: Sat Apr 01, 2006 11:07 am
by DilloDude
Create an integer variable: chan(or any name you want)
now, in your playsound code,
Code: Select all
chan=PlaySound2("data/sound", 1, 1, 0);
or whatever the playsound function uses. Using chan=PlaySound2 assigns the channel variable to that sound, or something like that. Now to stop the sound:
Code: Select all
stopSound(chan);


Just a note on the subject of sounds- tha pan value: this is the value for which speakers to play the sound from-left or right- and how much to play from each speaker. Now, normally this is set manually, but I have developed a function to return a variable based on the actor's xscreen coordinates. So then, in the playsound:
Code: Select all
PlaySound2("data/sound", 1, 1, Bal()));

I can post it later if anyone is interested.