Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: mmm_bot on Wed 19/06/2013 18:12:36

Title: Music continuing from the middle on restore?
Post by: mmm_bot on Wed 19/06/2013 18:12:36
Hey, I guess this might be a stupid question, but it's really bugging me - Everytime I save my game and then load it, the music continues from where it was the moment I saved the game. Is this a bug or some strange feature? Is there a way to make the music track start from the beginning when a player loads a game?

Thanks in advance!
Title: Re: Music continuing from the middle on restore?
Post by: Ghost on Wed 19/06/2013 18:38:50
That is exactly as intended. A game is saved "as it is at the moment of saving", so the music position is kept, too.

You can write your own function to restart the music though; one way would be to use a global audiochannel for the music and then manually reset it AFTER calling the restore command.
Title: Re: Music continuing from the middle on restore?
Post by: Crimson Wizard on Wed 19/06/2013 18:41:51
There's a way to respond to "game restored" event in game.

In GlobalScript.asc add "on_event" function:
Code (ags) Select

function on_event(EventType event, int data)
{
    if (event == eEventRestoreGame)
    {
        // reset your music here
    }
}



E: I must correct myself:
You don't have to put "on_event" function only in GlobalScript, you may as well put it in every room you have and do a specific action for each of them (if you need to).
Title: Re: Music continuing from the middle on restore?
Post by: mmm_bot on Wed 19/06/2013 22:34:51
Thanks a lot! Seemed weird to me that this is a feature - It's really weird to hear the middle of a track when you restore a game.
But at least there's an easy fix, so thanks :)