pixeltroid
Member
So I assign level music tracks for the rooms in my game in the room editors creation code.
My game requires the player to return to some rooms/levels so I have tried to set up a system that plays the proper track and also:
a) check if the level OST is already playing and prevent it from playing the same OST over itself.
b) check if another tract from another level is playing and fade it out.
Here's what the code looks like
So far, this only fades out the previous rooms track....BUT if I have, say, "ost_3" playing and I enter a room with the same track assigned to it, the track fades out in 3 seconds and the new instance of the same track starts playing from the start. I'm confused as to why its happening even
What am I doing wrong exactly?
How can I fix the code to make it so that the current track doesnt start playing over itself?
Any help would be appreciated!
My game requires the player to return to some rooms/levels so I have tried to set up a system that plays the proper track and also:
a) check if the level OST is already playing and prevent it from playing the same OST over itself.
b) check if another tract from another level is playing and fade it out.
Here's what the code looks like
Code:
//fades out track from previous room
if global.BGM!=ost_3
{
audio_sound_gain(global.BGM, 0, 3000);
}
//prevents the current track from playing
else if audio_is_playing(ost_3){
exit;
}
//plays main level music
audio_sound_gain(global.BGM, 0, 3000);
global.BGM = audio_play_sound(ost_3, 8, true);
What am I doing wrong exactly?
How can I fix the code to make it so that the current track doesnt start playing over itself?
Any help would be appreciated!
Last edited: