diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-11-19 17:30:23 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-11-19 17:30:23 +0200 |
| commit | 9ffb1eff073872df449a957c20154b9cc77f7ef7 (patch) | |
| tree | 5baab0ac4382179054b9d1014bef905ac11b475c | |
| parent | 30a3c440c3f18d7d2e0d6cb2e9c41f778922ba89 (diff) | |
Use get_node(name) instead of get_child(n) in Top
| -rw-r--r-- | top.gd | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -8,6 +8,7 @@ var save_state = ConfigFile.new() # Called when the node enters the scene tree for the first time. func _ready() -> void: var room = initial_room.instantiate() + room.name = "active_room" add_child(room) # Testing @@ -20,10 +21,11 @@ func _ready() -> void: func change_room(room_name: String): var room = ResourceLoader.load("res://room_" + room_name + ".tscn") - var current_room = get_child(0) + var current_room = get_node("active_room") remove_child(current_room) - var next_room = room.instantiate() + var next_room: Node = room.instantiate() + next_room.name = "active_room" add_child(next_room) func save(): |
