Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Mikael on September 02, 2007, 01:28:23 PM

Title: Playback of music files upon loading a saved game
Post by: Mikael on September 02, 2007, 01:28:23 PM
When a game is saved while a music channel is playing, upon loading the game, the music file starts up at the exact same place as it was when the game was saved. It might be a nice touch to let the music file start from the beginning instead, and give the load a "smoother" feel. Is this possible somehow?

And while we're on the topic: Is there any way to pause the music during the save/load screens ONLY?

Thanks in advance for any suggestions!

Mikael
Title: Re: Playback of music files upon loading a saved game
Post by: Mnemonic on September 02, 2007, 02:32:17 PM
Is this possible somehow?
Unfortunately not, the game continues where is stopped when the player saved the game.

And while we're on the topic: Is there any way to pause the music during the save/load screens ONLY?
You'd have to pause music before calling Game.SaveGame() / Game.LoadGame() and resume after the SaveGame() call.
Title: Re: Playback of music files upon loading a saved game
Post by: metamorphium on September 02, 2007, 02:49:35 PM
I think you can hijack the Game.AfterLoad event to start over the music.
Or is there a trap Mnemonic?

To be more specific I thought about something like this in the game.script:

on "AfterLoad"
{
  if (Game.IsMusicPlaying()) Game.SetMusicPosition(0);
}
Title: Re: Playback of music files upon loading a saved game
Post by: Mnemonic on September 02, 2007, 02:50:34 PM
The trap is you need to know what music file to start over.
Title: Re: Playback of music files upon loading a saved game
Post by: metamorphium on September 02, 2007, 02:54:00 PM
oops, you're always too fast.  ::beer
Title: Re: Playback of music files upon loading a saved game
Post by: Mikael on September 02, 2007, 05:53:04 PM
The trap is you need to know what music file to start over.

Exactly. But I'll keep it in mind if I'll make a game with only one music file in it. ;)

Thanks the both of you!

Mikael
Title: Re: Playback of music files upon loading a saved game
Post by: Mnemonic on September 02, 2007, 06:06:30 PM
Actually meta's solution should work universally. Obviously he's more creative with WME scripting than I am :)
Title: Re: Playback of music files upon loading a saved game
Post by: Mikael on September 03, 2007, 06:25:01 PM
Yippee! It really DOES work

My initial conclusion was, like Mnemonic's, that you needed to know which particular music file to start over. I tested it nonetheless, making the classic mistake of trying it out from old savegames. But, off course, Meta's simple yet perfect solution does the trick (which is kind of obvious at second glance).

It's so much nicer to load a game without being thrown into the middle of a music piece (or the last two notes, for that matter).

Thanks again, the both of you!

Mikael