fix: use ResourceLoader + remove_child before queue_free in SceneManager
This commit is contained in:
@@ -31,7 +31,7 @@ func _on_root_ready() -> void:
|
||||
|
||||
func transition_to(scene_name: String) -> void:
|
||||
var path: String = SCENES.get(scene_name, "")
|
||||
var packed: PackedScene = load(path) if path else null
|
||||
var packed := ResourceLoader.load(path, "PackedScene", ResourceLoader.CACHE_MODE_REUSE) as PackedScene
|
||||
if packed == null:
|
||||
push_error("[SceneManager] Scene not found: %s" % scene_name)
|
||||
return
|
||||
@@ -40,6 +40,7 @@ func transition_to(scene_name: String) -> void:
|
||||
push_error("[SceneManager] CurrentScene node not found in main.tscn")
|
||||
return
|
||||
if _current_scene_node != null:
|
||||
_current_scene_node.get_parent().remove_child(_current_scene_node)
|
||||
_current_scene_node.queue_free()
|
||||
_current_scene_node = null
|
||||
_current_scene_node = packed.instantiate()
|
||||
@@ -47,6 +48,7 @@ func transition_to(scene_name: String) -> void:
|
||||
|
||||
|
||||
func _on_game_started() -> void:
|
||||
# TODO next feature: call _load_for_role("chamber") here once role routing is implemented
|
||||
print("[SceneManager] Spiel gestartet — chamber transition kommt im nächsten Feature")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user