extends Node2D var main_menu_path:String = "res://Scenes/main_menu.tscn" var game_scene_path:String = "res://Scenes/game_scene.tscn" @export var levelcontainer: Node @export var ui: MainUI var level_path:String = "" func _ready() -> void: $levelcontainer/MainMenu.request_level_change.connect(start_loading) func start_loading(key:String): if key == "Game": ResourceLoader.load_threaded_request(game_scene_path) level_path = game_scene_path if !is_processing(): set_process(true) elif key == "MainMenu": ResourceLoader.load_threaded_request(main_menu_path) level_path = main_menu_path if !is_processing(): set_process(true) else: level_path = "" func _process(_delta): if level_path != "": var progress = [] var status = ResourceLoader.load_threaded_get_status(level_path, progress) if status == ResourceLoader.THREAD_LOAD_IN_PROGRESS: #THREADED_LOAD_IN_PROGRESS: print("Lädt: ", progress[0] * 100, "%") elif status == ResourceLoader.THREAD_LOAD_LOADED: # Fertig! Jetzt können wir das Level austauschen set_process(false) # Stop das Prüfen change_level() func change_level(): var new_level_resource = ResourceLoader.load_threaded_get(level_path) var new_level = new_level_resource.instantiate() if UiManager.game_guide.is_active: UiManager.mainUI.hide_game_guide() levelcontainer.add_child(new_level) levelcontainer.get_child(0).queue_free() if new_level.has_signal("request_level_change"): print("verbinde das siganl") new_level.request_level_change.connect(start_loading) new_level = "" func _on_game_guide_button_active() -> void: start_loading("Game")