Skip to content

Remove _exit_tree methods from Simple nodes#214

Merged
dbnicholson merged 1 commit intomainfrom
213-fix-simplecharacter
Sep 5, 2024
Merged

Remove _exit_tree methods from Simple nodes#214
dbnicholson merged 1 commit intomainfrom
213-fix-simplecharacter

Conversation

@manuq
Copy link
Copy Markdown
Contributor

@manuq manuq commented Sep 5, 2024

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

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
Copy link
Copy Markdown
Member

@dbnicholson dbnicholson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I totally misunderstood what _exit_tree was for. I think the reason I added that was that I was worried that sprite and/or collision would be created but then changed before before they were added to the node. But that can't happen with the current code since their created and added all within _ready.

@dbnicholson dbnicholson merged commit 67def96 into main Sep 5, 2024
@dbnicholson dbnicholson deleted the 213-fix-simplecharacter branch September 5, 2024 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SimpleCharacter texture can dissapear while editing

2 participants