63 lines
1.4 KiB
GDScript
63 lines
1.4 KiB
GDScript
extends CanvasLayer
|
|
|
|
signal fading_finished
|
|
signal transition_finished
|
|
|
|
@onready var big_fading = $BigFading
|
|
@onready var small_fading = $SmallFading
|
|
@onready var big_animation = $BigFading/BigFadingAnimation
|
|
@onready var small_animation = $SmallFading/SmallFadingAnimation
|
|
@onready var mask = $Mask
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
|
|
big_fading.visible = false
|
|
small_fading.visible = false
|
|
mask.visible = false
|
|
big_animation.connect("animation_finished", _on_animation_finished)
|
|
small_animation.connect("animation_finished", _on_animation_finished)
|
|
|
|
|
|
|
|
func _on_animation_finished(anim_name):
|
|
if anim_name == "fade_to_black":
|
|
fading_finished.emit()
|
|
big_animation.play("fade_to_normal")
|
|
small_animation.play("fade_to_normal")
|
|
|
|
elif anim_name == "fade_to_normal":
|
|
transition_finished.emit()
|
|
Globals.is_transitioning = false
|
|
big_fading.visible = false
|
|
small_fading.visible = false
|
|
|
|
|
|
|
|
#Handles fading transitions
|
|
func fading(size):
|
|
|
|
Globals.is_transitioning = true
|
|
|
|
if size == "big":
|
|
big_fading.visible = true
|
|
big_animation.play("fade_to_black")
|
|
elif size == "small":
|
|
small_fading.visible = true
|
|
small_animation.play("fade_to_black")
|
|
|
|
|
|
|
|
#Transitions the scenes
|
|
func transition(fading_screen_size, scenes_to_hide, scenes_to_show):
|
|
|
|
fading(fading_screen_size)
|
|
|
|
await self.fading_finished
|
|
|
|
for scene in scenes_to_hide:
|
|
scene.hide()
|
|
for scene in scenes_to_show:
|
|
scene.show()
|
|
|