From d27f978c627636df55b03fb64d2fea574e900756 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 21 Nov 2025 20:06:30 +0100 Subject: [PATCH] afegit fade de audio al final de Ending --- source/game/scenes/ending.cpp | 10 +++++++--- source/game/scenes/ending.hpp | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/game/scenes/ending.cpp b/source/game/scenes/ending.cpp index 9622141..ffd1cd2 100644 --- a/source/game/scenes/ending.cpp +++ b/source/game/scenes/ending.cpp @@ -156,7 +156,10 @@ void Ending::updateState(float delta_time) { break; case State::ENDING: - // Transición a ENDING2 + // Esperar ENDING_DURATION y luego transicionar a ENDING2 + if (state_time_ >= ENDING_DURATION) { + SceneManager::current = SceneManager::Scene::ENDING2; + } break; } } @@ -521,8 +524,9 @@ void Ending::checkChangeScene() { // Comprobar si ha pasado la duración de la escena if (state_time_ >= current_duration) { if (next_state == State::ENDING) { - // Termina el bucle - SceneManager::current = SceneManager::Scene::ENDING2; + // Transición al estado ENDING con fade de audio + transitionToState(State::ENDING); + Audio::get()->fadeOutMusic(MUSIC_FADE_DURATION); } else { // Transición a la siguiente escena current_scene_++; diff --git a/source/game/scenes/ending.hpp b/source/game/scenes/ending.hpp index b758b24..c4f034a 100644 --- a/source/game/scenes/ending.hpp +++ b/source/game/scenes/ending.hpp @@ -68,6 +68,8 @@ class Ending { static constexpr float IMAGE_REVEAL_SPEED = 60.0F; // 2px cada 2 frames @ 60fps static constexpr float TEXT_LAPSE = 1.333F; // 80 frames @ 60fps static constexpr float FADEOUT_START_OFFSET = 1.667F; // Inicio fade-out 100 frames antes del fin + static constexpr float ENDING_DURATION = 2.0F; // Duración del estado ENDING (2 segundos) + static constexpr int MUSIC_FADE_DURATION = 1800; // Fade de audio en milisegundos (1.8 segundos) // --- Métodos --- void update(); // Actualiza el objeto