Tweak default music fade duration
This commit is contained in:
parent
28b6d0fc7c
commit
1d0f1bae80
@ -6,7 +6,7 @@ var animation_duration : float
|
|||||||
var target_track : AudioStreamPlayer
|
var target_track : AudioStreamPlayer
|
||||||
var previous_tracks : Array
|
var previous_tracks : Array
|
||||||
|
|
||||||
func play(music, offset=0, duration=2):
|
func play(music, offset=0, duration=1):
|
||||||
print('Play music: ' + music)
|
print('Play music: ' + music)
|
||||||
var path = "res://sounds/" + music + ".ogg"
|
var path = "res://sounds/" + music + ".ogg"
|
||||||
if !File.new().file_exists(path):
|
if !File.new().file_exists(path):
|
||||||
@ -25,7 +25,7 @@ func play(music, offset=0, duration=2):
|
|||||||
target_track.stream = stream
|
target_track.stream = stream
|
||||||
target_track.play(offset)
|
target_track.play(offset)
|
||||||
|
|
||||||
func fade_out(duration=2):
|
func fade_out(duration=1):
|
||||||
target_track = null
|
target_track = null
|
||||||
previous_tracks = get_playing_tracks()
|
previous_tracks = get_playing_tracks()
|
||||||
fading = true
|
fading = true
|
||||||
@ -57,9 +57,9 @@ func _process(delta):
|
|||||||
var p = clamp(animation_time / animation_duration, 0, 1)
|
var p = clamp(animation_time / animation_duration, 0, 1)
|
||||||
|
|
||||||
if target_track != null:
|
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:
|
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:
|
if p == 1:
|
||||||
fading = false
|
fading = false
|
||||||
|
Loading…
Reference in New Issue
Block a user