scene_manager.gd 812 B
extends Node
var current_scene = null
@onready var fade_animation: AnimationPlayer = $CanvasLayer/AnimationPlayer
func _ready() -> void:
start_game("res://scenes/title_screen.tscn")
# Initial start up scene for client, should be title screen
func start_game(scene_path: String) -> void:
var new_scene = load(scene_path).instantiate()
get_parent().add_child.call_deferred(new_scene)
current_scene = new_scene
# Change current scene
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")
func add_scene(scene_path: String) -> void:
pass