How to play a music just after the previous song is ended?

Started by JLM_82, Thu 10/06/2021 09:55:21

Previous topic - Next topic

JLM_82

Hi,

Let's assume there is a room in the game that has so-called intro-music that is played, when the player enters to the room. When the intro-music is ended, the "main" music starts and loops as long as the player is in the room.

Is there a useful way in AGS to implement this kind of functionality? To check, if "previous" music is ended, and just then start the new one, and let it loop, until the player leaves the room?

Vincent

It should be something like this:

Code: ags

aIntroMusic.Play(eAudioPriorityNormal, eOnce);
aMainMusic.PlayQueued(eAudioPriorityNormal, eRepeat);


Khris

Correct, however this will only work as expected if there's only one channel available for the sound type. That might be the default for music anyway, just thought I'd point it out.

Trumgottist

Quote from: Khris on Fri 11/06/2021 10:45:23
Correct, however this will only work as expected if there's only one channel available for the sound type. That might be the default for music anyway, just thought I'd point it out.
Does this mean that this sort of thing is not possible to setup if you want more than one music channel? I'm assuming that is a setting that can't be changed while running the game.

I have found the "crossfade tracks" setting in the audio properties. That would possibly solve that problem (since transitions are the main thing I imagine I'd want to use multiple music channels for), but only if it can be toggled by a script, and I haven't found how to do that. Is that possible? I want to crossfade the music in general, but I also want the ability to do a hard cut between scenes.

Khris

Take a look at the manual's section for SetGameOption (in Global functions (general section)).

Code: ags
  SetGameOption(OPT_CROSSFADEMUSIC, 0); // turn off cross fading
  SetGameOption(OPT_CROSSFADEMUSIC, 1); // slow cross fading
                              // or 2, 3
  SetGameOption(OPT_CROSSFADEMUSIC, 4); // fast fading

SMF spam blocked by CleanTalk