extends CanvasLayer

signal fade_finished

var _current_scene: Node = null;
var _next_scene: Node = null;


var _BLACK_COLOR = Color(0,0,0,1)
var _TRANSPARENT_COLOR = Color(0,0,0,0)

func _ready() -> void:
	fade_in()


func fade_in(sec:float = .2):
	$Tween.stop_all()
	$Tween.interpolate_property($ColorRect, "color", $ColorRect.color, _TRANSPARENT_COLOR, sec)
	$Tween.start()
	
func fade_out(sec:float = .2):
	$Tween.stop_all()
	$Tween.interpolate_property($ColorRect, "color", $ColorRect.color, _BLACK_COLOR, sec)
	$Tween.start()
	


func _on_Tween_tween_completed(object: Object, key: NodePath) -> void:
	emit_signal("fade_finished")
