Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candle on Tue 10/01/2006 09:40:55

Title: When sound stops move to next room
Post by: Candle on Tue 10/01/2006 09:40:55
I trying to have it were you click on a swtich and the sound plays when it stops you go to the next room.
Bur right now it goes to soon.

// script for Object 0: Interact object
object[0].Animate(0, 5);
PlaySoundEx(12, 4);
Wait(120);
object[0].Visible = false;
character[GIRL].ChangeRoom(50, 100, 50);

Not sure what I'm doing wrong as I was just trying things to see if they would work or not.
Thanks for any help
get back later today when I wake up . been up all night and need some sleep.
Title: Re: When sound stops move to next room
Post by: Gilbert on Tue 10/01/2006 11:09:04
How long is the sound?
By default Wait(120) waits for 3 seconds.
Title: Re: When sound stops move to next room
Post by: Candle on Tue 10/01/2006 11:16:55
It's about 10 sec long.so I would have to add more or a way to make it wait till the sound ends?
Title: Re: When sound stops move to next room
Post by: Ashen on Tue 10/01/2006 12:13:57
Yes, you'll have to make the wait longer. If the track is 10 seconds, use Wait(400); or Wait(GetGameSpeed() * 10);.

However, since you're using PlaySoundEx() you could use IsChannelPlaying() in repeatedly_execute instead - it's more coding, but this way you won't have to work out the exact delay. You'll also need a variable, to check the sound has been started, something like:


// Main room script
int playing;


// script for Object 0: Interact object
object[0].Animate(0, 5);
PlaySoundEx(12, 4);
playing = 1;
object[0].Visible = false;


//repeatedly_execute
if (IsChannelPlaying(4)) Wait(1); // while track is playing, wait
else if (playing == 1) {
  character[GIRL].ChangeRoom(50, 100, 50); // Track has stopped, so change room
  playing = 0;
}


That should work OK.
Title: Re: When sound stops move to next room
Post by: Candle on Tue 10/01/2006 12:21:49
Works perfect, thank you so much ..