Title music fades in/out

This commit is contained in:
Kae 2023-06-30 12:02:00 +10:00
parent 33b980dacb
commit ee2e134bbf
2 changed files with 7 additions and 1 deletions

View File

@ -126,7 +126,9 @@ void TitleScreen::update() {
if (!finishedState()) { if (!finishedState()) {
if (auto audioSample = m_musicTrackManager.updateAmbient(m_musicTrack, m_skyBackdrop->isDayTime())) { if (auto audioSample = m_musicTrackManager.updateAmbient(m_musicTrack, m_skyBackdrop->isDayTime())) {
m_currentMusicTrack = audioSample;
audioSample->setMixerGroup(MixerGroup::Music); audioSample->setMixerGroup(MixerGroup::Music);
audioSample->setLoops(0);
m_mixer->play(audioSample); m_mixer->play(audioSample);
} }
} }
@ -153,6 +155,8 @@ bool TitleScreen::finishedState() const {
void TitleScreen::resetState() { void TitleScreen::resetState() {
switchState(TitleState::Main); switchState(TitleState::Main);
if (m_currentMusicTrack)
m_currentMusicTrack->setVolume(1.0f, 4.0f);
} }
void TitleScreen::goToMultiPlayerSelectCharacter(bool skipConnection) { void TitleScreen::goToMultiPlayerSelectCharacter(bool skipConnection) {
@ -161,7 +165,8 @@ void TitleScreen::goToMultiPlayerSelectCharacter(bool skipConnection) {
} }
void TitleScreen::stopMusic() { void TitleScreen::stopMusic() {
m_musicTrackManager.cancelAll(); if (m_currentMusicTrack)
m_currentMusicTrack->stop(8.0f);
} }
PlayerPtr TitleScreen::currentlySelectedPlayer() const { PlayerPtr TitleScreen::currentlySelectedPlayer() const {

View File

@ -124,6 +124,7 @@ private:
SkyPtr m_skyBackdrop; SkyPtr m_skyBackdrop;
AmbientNoisesDescriptionPtr m_musicTrack; AmbientNoisesDescriptionPtr m_musicTrack;
AudioInstancePtr m_currentMusicTrack;
AmbientManager m_musicTrackManager; AmbientManager m_musicTrackManager;
}; };