shoDater/scenes/global/assets/scripts/fadetoblack.gd

37 lines
719 B
GDScript

extends ColorRect
var fade = false
var unfade = false
var transparency = 0
func _process(_delta):
if fade and not unfade:
await get_tree().create_timer(0.01).timeout
if color.a < 1:
color = Color(0, 0, 0, transparency)
else:
color = Color(0, 0, 0, 1)
fade = false
transparency += 0.01
if unfade and not fade:
await get_tree().create_timer(0.01).timeout
if color.a > 0:
color = Color(0, 0, 0, transparency)
else:
color = Color(0, 0, 0, 0)
unfade = false
transparency -= 0.01
if fade and unfade:
color = Color(0, 0, 0, 100)
func _on_dialog_fade_to_black():
transparency = 0
unfade = false
fade = true
func _on_dialog_unfade():
transparency = 1
fade = false
unfade = true