Tough_Crowd/godot/scenes/boot/bootsplash_scene.gd

45 lines
1.0 KiB
GDScript3
Raw Permalink Normal View History

2024-01-26 18:01:32 +00:00
class_name BootsplashScene
extends Control
2024-01-28 11:32:09 +00:00
@export var fade_duration: float = 1.0
@export var stay_duration: float = 1.5
@export var node: PackedScene
@export var next_scene: PackedScene
@export var interuptable: bool = true
2024-01-26 18:01:32 +00:00
@onready var control = %NodeContainer
2024-01-28 11:32:09 +00:00
@onready var instance: Node2D = node.instantiate()
2024-01-26 18:01:32 +00:00
func _ready():
instance.modulate.a = 0.0
control.add_child(instance)
var tween = create_tween()
tween.set_trans(Tween.TRANS_CUBIC)
tween.set_ease(Tween.EASE_IN)
2024-01-28 11:32:09 +00:00
tween.tween_property(instance, "modulate:a", 1.0, fade_duration).from(0.0).finished.connect(
_fade_out
)
2024-01-26 18:01:32 +00:00
func _process(_delta):
if interuptable and Input.is_action_just_pressed("exit"):
_change_scene()
2024-01-28 11:32:09 +00:00
2024-01-26 18:01:32 +00:00
func _fade_out():
var tween = create_tween()
tween.set_trans(Tween.TRANS_CUBIC)
tween.set_ease(Tween.EASE_IN)
2024-01-28 11:32:09 +00:00
(
tween
. tween_property(instance, "modulate:a", 0.0, fade_duration)
. set_delay(stay_duration)
. finished
. connect(_change_scene)
)
2024-01-26 18:01:32 +00:00
func _change_scene():
get_tree().change_scene_to_packed(next_scene)