mirror of
https://github.com/kodzukye/scrap-signal.git
synced 2026-04-26 19:17:35 +00:00
29 lines
716 B
GDScript
29 lines
716 B
GDScript
# loading_zone.gd
|
|
extends Area2D
|
|
|
|
@export var target_scene: String = "res://levels/atelier/atelier.tscn"
|
|
@export var fade_duration: float = 0.6
|
|
|
|
@onready var fade_rect: ColorRect = $TransitionLayer/FadeRect
|
|
|
|
var _transitioning := false
|
|
|
|
func _ready() -> void:
|
|
fade_rect.modulate.a = 0.0
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
print("Body entered")
|
|
if _transitioning:
|
|
return
|
|
if body.is_in_group("player"):
|
|
_transitioning = true
|
|
_start_transition()
|
|
|
|
func _start_transition() -> void:
|
|
var tween := create_tween()
|
|
tween.tween_property(fade_rect, "modulate:a", 1.0, fade_duration)
|
|
tween.tween_callback(func():
|
|
get_tree().change_scene_to_file(target_scene)
|
|
)
|