Hi!
I have a weird problem in my game: sometimes playing an audio stops the background music.
I have narrowed down WHEN it happens, but I don't know why or how I can solve the problem.
After an intro screen, the player enters the main room. There I start the music in room_FirstLoad()
Code: ags
Which works as expected. Later in the game, I play a sound when looking at an inventory item
Code: ags
This sometimes stops the background music and it doesn't start again.
The weirdest thing is, when this happens. Because it all depends on the first intro screen.
The full room script:
Code: ags
When I cancel the screen with ESC, everything is ok. But when I wait for the cutscene to finish, the aRubberDuck.Play() will stop the music later in the game.
What I intend to do is showing the intro screen and play the sound and only navigate to the main screen when the music has finished. When the user presses ESC, the game should stop the sound and switch to the main screen immediately.
My guess is, that aStart.Stop causes some internal error when the audio is not playing anymore, but I'm not sure.
Is my description clear? I know it sounds very confusing.
Is there a workaround for this problem?
Edit: I'm using AGS 3.3.3
I have a weird problem in my game: sometimes playing an audio stops the background music.
I have narrowed down WHEN it happens, but I don't know why or how I can solve the problem.
After an intro screen, the player enters the main room. There I start the music in room_FirstLoad()
aKanji.Play(eAudioPriorityNormal, eRepeat);
Which works as expected. Later in the game, I play a sound when looking at an inventory item
aRubberDuck.Play();
This sometimes stops the background music and it doesn't start again.
The weirdest thing is, when this happens. Because it all depends on the first intro screen.
The full room script:
function room_AfterFadeIn()
{
StartCutscene(eSkipESCOnly);
Wait(6 * GetGameSpeed());
EndCutscene();
aStart.Stop();
player.ChangeRoom(1);
}
function room_Load()
{
gInventory.Visible = false;
aStart.Play(eAudioPriorityNormal, eOnce);
}
When I cancel the screen with ESC, everything is ok. But when I wait for the cutscene to finish, the aRubberDuck.Play() will stop the music later in the game.
What I intend to do is showing the intro screen and play the sound and only navigate to the main screen when the music has finished. When the user presses ESC, the game should stop the sound and switch to the main screen immediately.
My guess is, that aStart.Stop causes some internal error when the audio is not playing anymore, but I'm not sure.
Is my description clear? I know it sounds very confusing.
Is there a workaround for this problem?
Edit: I'm using AGS 3.3.3