From 1d0f1bae800613a350052b5014de67a9bc99f670 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 18 Aug 2020 12:02:14 +0200 Subject: [PATCH] Tweak default music fade duration --- scripts/MusicPlayer.gd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/MusicPlayer.gd b/scripts/MusicPlayer.gd index c141403..ca60bf9 100644 --- a/scripts/MusicPlayer.gd +++ b/scripts/MusicPlayer.gd @@ -6,7 +6,7 @@ var animation_duration : float var target_track : AudioStreamPlayer var previous_tracks : Array -func play(music, offset=0, duration=2): +func play(music, offset=0, duration=1): print('Play music: ' + music) var path = "res://sounds/" + music + ".ogg" if !File.new().file_exists(path): @@ -25,7 +25,7 @@ func play(music, offset=0, duration=2): target_track.stream = stream target_track.play(offset) -func fade_out(duration=2): +func fade_out(duration=1): target_track = null previous_tracks = get_playing_tracks() fading = true @@ -57,9 +57,9 @@ func _process(delta): var p = clamp(animation_time / animation_duration, 0, 1) if target_track != null: - target_track.volume_db = lerp(-90, 0, clamp(p * 2, 0, 1)) + target_track.volume_db = lerp(-90, 0, p) for previous_track in previous_tracks: - previous_track.volume_db = lerp(0, -90, clamp((p * 2) - 1, 0, 1)) + previous_track.volume_db = lerp(0, -90, p) if p == 1: fading = false