How to keep a sound play in the background?
For example,let the sound of ocean keep playing,or wind blowing,and others...
I tried,but there is always some errors...
This is my first file:
void main(void)
{
int &wait;
loop:
&wait = random(3000,2000);
wait(&wait);
playsound(50,20000,0,¤t_sprite,0);
goto loop
}
And when I attach it to a stone,the game just crashed...
Awk...
I tried,but there is always some errors...
This is my first file:
void main(void)
{
int &wait;
loop:
&wait = random(3000,2000);
wait(&wait);
playsound(50,20000,0,¤t_sprite,0);
goto loop
}
And when I attach it to a stone,the game just crashed...
Awk...
There is a way... I wouldn't attach the sound or the script to a sprite though, when you do that the sound fades when you get further away, so if you wanted wind blowing, you might want it to be consistant throught the screen.
Also, I don't see why there needs to be a random wait time, but you might have some purpose or reason for that.
Also, I don't see why there needs to be a random wait time, but you might have some purpose or reason for that.
Try something like this:
Attach this to every screen you want the ocean/wind blow on and it should work.
Just be sure to change the ##'s and the 'length of sound'.
EDIT: I'm pretty sure you can attach it to any sprites or just the base of the screen. What I've done when I do this, is:
void main ( void ) { int &chk_map; sndloop: playsound(##, #####, 0, 0, 0); wait(length of sound); &chk_map = &player_map; if (&chk_map != &player_map) kill_this_task(); goto sndloop; }
Attach this to every screen you want the ocean/wind blow on and it should work.
Just be sure to change the ##'s and the 'length of sound'.
EDIT: I'm pretty sure you can attach it to any sprites or just the base of the screen. What I've done when I do this, is:
int &lala = create_sprite(0, 0, 0, 0, 0); sp_script(&lala, "script");
Of course,the waves won't hit the coast exactly 3 times a minute...So there must be a random time gap between two sounds.
Oh,thanks,you are really of great help.
Er...but...there seems to be some kind of...echo?
Or that's many sound plays onr after another?
Or that's many sound plays onr after another?
Hmmm... Did you set the wait(); to the same length as the sound?
EDIT: By the way, your first script might have crashed the game because your 'goto' line didn't have a semi colon. you had:
goto loop
you should have had:
goto loop;
EDIT: By the way, your first script might have crashed the game because your 'goto' line didn't have a semi colon. you had:
goto loop
you should have had:
goto loop;
Umm...does it matter?
Yes, the reason it echos is because it's not waiting the full length of the sound, which means you have two instances of the same sound playing over the top. You must set the wait(); to either the same length as the sound or longer.
Ummmmmm...That's reasonable...
The script in the original post looks okay, except you're missing a ; after goto loop. Possibly, using &wait as the name of the local could also be problematic... but probably not.
If you attach that script to a sprite on a screen, it should work just fine, as long as you have a sound loaded in slot 50. Trying to play a nonexistant sound will crash the game.
If you attach that script to a sprite on a screen, it should work just fine, as long as you have a sound loaded in slot 50. Trying to play a nonexistant sound will crash the game.
It worked!!
Thank you!!
Er...All of you!
Thank you!!
Er...All of you!