godot-vn/transition.gd

34 lines
751 B
GDScript3
Raw Normal View History

2018-09-21 03:37:07 +01:00
extends Control
onready var background = get_node("background")
onready var tween = get_node("tween")
2018-09-21 03:54:04 +01:00
signal on_transition_time()
2018-09-21 03:37:07 +01:00
signal on_transition_completed()
const TRANSITION_TIME = 1.0
func _ready():
pass
2018-09-29 18:34:20 +01:00
func start_transition(time_in = TRANSITION_TIME, time_out = TRANSITION_TIME):
2018-09-21 03:37:07 +01:00
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")
2018-09-21 03:54:04 +01:00
emit_signal("on_transition_time")
2018-09-21 03:37:07 +01:00
tween.interpolate_property(
background, "color:a", background.color.a, 0.0,
TRANSITION_TIME, Tween.TRANS_QUAD,
Tween.EASE_IN_OUT
)
tween.start()
2018-09-21 03:54:04 +01:00
yield(tween, "tween_completed")
emit_signal("on_transition_completed")
2018-09-21 03:37:07 +01:00