Music pause function? crossfade?

Started by Anarcho, Thu 08/05/2008 03:26:53

Previous topic - Next topic

Anarcho

Two questions, is there a Music Pause function?  I'd like to temporarily pause the music in a cutscene and then let it start again later from the same place.  Secondly, i can't find a function to set the type of crossfading in the game...there's just the option to change it in the General Settings tab.

I'm using Build 3.0.0.23.

Thanks!

Logan


monkey0506

#1
You could do something along the lines of this:

Code: ags
int music_pos = -1;
int music_num = -1;
int music_type = -1;

function PauseMusic() {
  music_num = GetCurrentMusic();
  if (music_num == -1) return;
  music_pos = GetMP3PosMillis();
  music_type = 0;
  if (!music_pos) {
    music_pos = GetMIDIPosition();
    music_type = 1;
  }
  if (music_pos == -1) {
    music_pos = Game.GetMODPattern();
    music_type = 2;
  }
  if (music_pos == -1) {
    // this shouldn't happen, but it's just a safety catch
    music_num = -1;
    music_type = -1;
    return;
  }
  StopMusic();
}

function UnPauseMusic() {
  if ((music_num == -1) || (music_pos == -1) || (music_type == -1)) return;
  PlayMusic(music_num);
  if (music_type == 0) SeekMP3PosMillis(music_pos);
  else if (music_type == 1) SeekMIDIPosition(music_pos);
  else if (music_type == 2) SeekMODPattern(music_pos);
  else StopMusic();
  music_num = -1;
  music_pos = -1;
  music_type = -1;
  }


As for crossfading you'll need to check SetGameOption, specifically the OPT_CROSSFADEMUSIC option.

Anarcho



SMF spam blocked by CleanTalk