From ec063a7d67587b7827f4a57820ff1b58df554c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Thu, 5 Sep 2024 10:38:00 -0300 Subject: [PATCH] Remove _exit_tree methods from Simple nodes There is no need for this cleanup because from docs: [1] > If the node has children, its _exit_tree callback will be called last, > after all its children have left the tree. Also because: [2] > when a node is freed with Object.free or queue_free, it will also free > all its children. Further, this removes the sprite and collision while in the editor when the user switches to another scene tab #213. [1] https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-private-method-exit-tree [2] https://docs.godotengine.org/en/stable/classes/class_node.html#description Fixes #213 --- .../simple_nodes/simple_character/simple_character.gd | 10 ---------- .../simple_nodes/simple_scoring/simple_scoring.gd | 6 ------ 2 files changed, 16 deletions(-) diff --git a/addons/block_code/simple_nodes/simple_character/simple_character.gd b/addons/block_code/simple_nodes/simple_character/simple_character.gd index 90987be1..4a934b1e 100644 --- a/addons/block_code/simple_nodes/simple_character/simple_character.gd +++ b/addons/block_code/simple_nodes/simple_character/simple_character.gd @@ -72,16 +72,6 @@ func simple_setup(): _texture_updated() -func _exit_tree(): - if collision: - collision.queue_free() - collision = null - - if sprite: - sprite.queue_free() - sprite = null - - func get_custom_class(): return "SimpleCharacter" diff --git a/addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd b/addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd index 185fcba9..c1b2104b 100644 --- a/addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd +++ b/addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd @@ -63,12 +63,6 @@ func simple_setup(): add_child(right_label) -func _exit_tree(): - for label in _score_labels.values(): - label.queue_free() - _score_labels.clear() - - func get_custom_class(): return "SimpleScoring"