Is there a way to keep music from restarting when you re-enter a room? I use a separate room for dialogue, so having the music restart when you exit the dialog area is a real pain. I saw a previous post solving it, but the code provided didn't work. I suppose it's because of the newer version? Please help O.o for now I'm putting songs in the que, but that really doesn't help when I need a song to change immediately.
The basic idea is to have a global AudioChannel* pointer and instead of simply starting the music, only to start it if the Channel isn't already playing it.
// add this to GlobalScript.ash
import void SetBGM(AudioClip *music);
// add this to the top of GlobalScript.asc
AudioChannel *bgm;
void SetBGM(AudioClip *music) {
if (bgm == null || bgm.PlayingClip != music) bgm = music.Play();
}
Now simply call SetBGM(aTheMusic); in your room's before fadein event.
Edit: instead of adding room_Load to tons of rooms, one can also use on_event:
function on_event(EventType event, int data) {
if (event == eEventEnterRoomBeforeFadein) {
if (data >= 3 && data <= 9) SetBMG(aOcean);
if (data >= 10 && data <= 14) SetBGM(aCave);
// etc.
}
}
I got this:
(http://i58.tinypic.com/2ebv6ys.jpg)
You're right, I imported bgm instead of declaring it. Code should be fixed now.
It's perfect now. THANKS