2
0
Эх сурвалжийг харах

Free orphan nodes after removing them

Aaron Franke 5 жил өмнө
parent
commit
cf45430744
1 өөрчлөгдсөн 3 нэмэгдсэн , 2 устгасан
  1. 3 2
      main/main.gd

+ 3 - 2
main/main.gd

@@ -17,8 +17,9 @@ func replace_main_scene(resource):
 func change_scene(resource : Resource):
 	var node = resource.instance()
 	
-	while get_child_count() > 0:
-		remove_child(get_child(0))
+	for child in get_children():
+		remove_child(child)
+		child.queue_free()
 	add_child(node)
 	
 	node.connect("quit", self, "go_to_main_menu")