I'm trying to put multiple songs in my game with each playing at a different point but the music

R

RetroCop

Guest
keeps stacking (playing at the same time). I'm using a specific object to play the music and here is my code

if room=rm_title || room=rm_menu audio_play_sound(snd_titlemusic,0,1)
else
{
audio_stop_sound(snd_titlemusic)
}

if instance_exists(obj_player) audio_play_sound(snd_music1,0,1)
else
{
audio_stop_sound(snd_music1)
}
 
A

Aura

Guest
The code actually doesn't explain what you're trying to do, so some sort of explanation would be appreciated.
 
R

RetroCop

Guest
The code actually doesn't explain what you're trying to do, so some sort of explanation would be appreciated.
I'm trying to basically add a soundtrack to my game, I want to play different music in different rooms without the previous music playing over the new one but I can't seem to figure out how.
 
N

Noyemi K

Guest
You might want to use audio_stop_all to stop all sounds before queueing the next track.

Additionally, when you play a sound, it returns an index for the sound instance which is used for actually stopping said instance. If you didn't want to use audio_stop_all, you'd want to do
Code:
background_music = audio_play_sound(snd_titlemusic,0,1)
to store the index and then do
Code:
audio_stop_sound(background_music)
Otherwise, it won't perform as you expect because it doesn't have an instance to work with.
 
Top