From e4702e4e24bef7ee89411fe55ad24efbd3cf79d9 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 24 Aug 2025 17:39:07 +0200 Subject: [PATCH] bug fix: Audio::fadeOutMusic no ha de fer fade si la musica no sona --- source/audio.cpp | 2 +- source/sections/game.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/audio.cpp b/source/audio.cpp index d99006a..3fde5f4 100644 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -100,7 +100,7 @@ void Audio::stopAllSounds() const { // Realiza un fundido de salida de la música void Audio::fadeOutMusic(int milliseconds) const { - if (music_enabled_) { + if (music_enabled_ && music_.state == MusicState::PLAYING) { #ifndef NO_AUDIO JA_FadeOutMusic(milliseconds); #endif diff --git a/source/sections/game.cpp b/source/sections/game.cpp index ac7303f..81e7f1c 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -378,15 +378,6 @@ void Game::updateGameStateCompleted() { updatePathSprites(); cleanVectors(); - // Para la música y elimina todos los globos e items - if (game_completed_counter_ == 0) { - stopMusic(); // Detiene la música - balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos - playSound("power_ball_explosion.wav"); // Sonido de destruir todos los globos - destroyAllItems(); // Destruye todos los items - background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas - } - // Comienza las celebraciones // Muestra el mensaje de felicitación y da los puntos a los jugadores if (game_completed_counter_ == START_CELEBRATIONS) { @@ -1825,6 +1816,19 @@ void Game::checkAndUpdateBalloonSpeed() { void Game::setState(State state) { state_ = state; counter_ = 0; + + switch (state) { + case State::COMPLETED: // Para la música y elimina todos los globos e items + stopMusic(); // Detiene la música + balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos + playSound("power_ball_explosion.wav"); // Sonido de destruir todos los globos + destroyAllItems(); // Destruye todos los items + background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas + break; + + default: + break; + } } void Game::playSound(const std::string &name) const {