sound keeps looping

Posted By: abbicon

sound keeps looping - 10/16/06 02:50

I have a WAV file that i want to play once, but when i load the sound in WED and build and run my level it continues to loop. I have looked at my main WDL file with SED and i have right clicked on the speaker icon in WED but i cant seem to find where to set this to only play once.. any help is appreciated.

Thanks Jeff
Posted By: Damocles

Re: sound keeps looping - 10/17/06 17:09

snd_loop(mysound,100,0);

->


snd_play(mysound,100,0);

if this is not the error:

you start the sound again and again by some other function.
Posted By: MichaelSoko

Re: sound keeps looping - 10/17/06 17:10

Sorry my english is not perfect (<< German user) but i'll try my best!

First of all, don't add sounds in WED. Try to do it with scripting.

snd_loop for endless sound-loops and

snd_play for playing it once.
Posted By: anonymous_alcoho

Re: sound keeps looping - 10/17/06 19:12

In the script, use a handle.

Example:

Code:

function playSomeSound()
{
if(snd_playing(mySnd) != 1)
{
mySnd = snd_play(aSound,25,0);
}
else
{
return;
}
}



Now everytime playSomeSound() is called, it first checks if the sound is playing (snd_playing). If not, it plays the sound. If the sound is playing, it simply returns.
Posted By: abbicon

Re: sound keeps looping - 10/18/06 21:52

guys thanks for the help, I however cant code at all. where do i place these lines of code and how do i call them. This is another example of my frustration with this software, If i shouldnt add sounds in WED then why can I ? and if there is a better or more effective way to do it why cant i find it in the documentation ? this is the stuff that drives me nuts, i'ts not like what i am asking is an unusual request. I have a static model that i want to play a sound when the player is near but only once per level, so i waste my time adding the sound through WEd and then trying to figure out why it wont work. ATTENTION CONITEC: COMMON THINGS LIKE THIS SHOULD BE ADDRESSED IN THE MANUAL AS SHOULD MOST OF THE ISSUES ADDRESSED IN "STARTING WITH GAMESTUDIO" IF YOU GO BACK THROUGH THE ARCHIVED PAGES I AM SURE YOU WILL FIND MANY PEOPLE ASKING THE SAME QUESTIONS OVER AND OVER (SLIDING DOORS, CLIMBING LADDERS ETC.)- DONT RELY ON THE COMMUNITY TO ANSWER THESE I WANT ANSWERS FROM THE PEOPLE I PAID MY MONEY TO. Dont get me wrong This is the best on-line community that i have ever been involved with but 1 problem could have 3 different solutions and all may not work in a given situation. I want the people that wrote the engine and developed the templates to address these issues so that you can truely make a game without coding. When i first started with A4 I ran into some of the same issues (common game element couldnt be implemented I.E. climbing ladders and couldnt find any help in the manual at all.) this is even more frustrating because WED lets me load and add sounds but apparently it has to loop continuosly if that is the case then the manual should say "If you want ambient sound in your level you can add a looping .WAV file that will play in the background, however if you would like the sound not to loop you need to add it with code and if you dont know how to code sell your game only to deaf people - have a nice day!" rant officially over.
Posted By: anonymous_alcoho

Re: sound keeps looping - 10/19/06 02:15

The code I gave you technically isn't a loop, it was just an example to show how snd_playing() worked. However, everything you need to know about sounds, loops and such are in the manual. I learned from the manual and this forum and the occasional tutorial.

Code:

function playBgMusic()
{
while(1)
{
if(snd_playing(mySnd) != 1)
{
mySnd = snd_play(mySnd,50,0);
}
wait(1);
}
}




Call it in function main.
© 2024 lite-C Forums