Skip to content
Snippets Groups Projects
scene_manager.gd 511 B
extends Node

var current_scene = null

@onready var fade_animation: AnimationPlayer = $CanvasLayer/AnimationPlayer

func _ready() -> void:
	change_scene("res://scenes/title_screen.tscn")

func change_scene(scene_path: String) -> void:
	fade_animation.play("fade_out")
	await fade_animation.animation_finished
	
	if current_scene:
		current_scene.queue_free()
		
	var new_scene = load(scene_path).instantiate()
	
	get_parent().add_child(new_scene)
	current_scene = new_scene
	
	fade_animation.play("fade_in")