godot-vn/transition.gd

34 lines
698 B
GDScript

extends Control
onready var background = get_node("background")
onready var tween = get_node("tween")
signal on_transition_time()
signal on_transition_completed()
const TRANSITION_TIME = 1.0
func _ready():
pass
func start_transition():
tween.interpolate_property(
background, "color:a", background.color.a, 1.0,
TRANSITION_TIME, Tween.TRANS_QUAD,
Tween.EASE_IN_OUT
)
tween.start()
yield(tween, "tween_completed")
emit_signal("on_transition_time")
tween.interpolate_property(
background, "color:a", background.color.a, 0.0,
TRANSITION_TIME, Tween.TRANS_QUAD,
Tween.EASE_IN_OUT
)
tween.start()
yield(tween, "tween_completed")
emit_signal("on_transition_completed")