mirror of
https://github.com/kodzukye/omens-ascent.git
synced 2026-08-10 13:23:10 +00:00
28 lines
666 B
GDScript
28 lines
666 B
GDScript
class_name LoadingZone
|
|
extends Area2D
|
|
|
|
@export var target_scene: String
|
|
@export var fade_duration: float = 0.6
|
|
|
|
@onready var fade_rect: ColorRect = $TransitionLayer/FadeRect
|
|
|
|
var _transitioning: bool = false
|
|
|
|
func _ready() -> void:
|
|
fade_rect.modulate.a = 0.0
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if _transitioning:
|
|
return
|
|
if body.is_in_group("player"):
|
|
_transitioning = true
|
|
_start_transition()
|
|
|
|
func _start_transition() -> void:
|
|
var tween: Tween = create_tween()
|
|
tween.tween_property(fade_rect, "modulate:a", 1.0, fade_duration)
|
|
tween.tween_callback(func():
|
|
SceneManager.change_scene(target_scene)
|
|
)
|