Skip to content

SimpleCharacter: Don't impose a collision shape #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

manuq
Copy link
Contributor

@manuq manuq commented Sep 5, 2024

Change the logic so there is no fallback 100x100 collision shape if a
texture is not provided. This way the user can customize their character
by adding their own sprites and collision shapes as node children. The
simple setup of passing a texture is still maintained. Although it has
been found to be inflexible (can't resize the texture from the canvas,
can't change the shape of the collision).

Addresses #215

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
Change the logic so there is no fallback 100x100 collision shape if a
texture is not provided. This way the user can customize their character
by adding their own sprites and collision shapes as node children. The
simple setup of passing a texture is still maintained. Although it has
been found to be inflexible (can't resize the texture from the canvas,
can't change the shape of the collision).

Addresses #215
@manuq
Copy link
Contributor Author

manuq commented Sep 5, 2024

Note: this is on top of #214

@manuq manuq changed the title No imposed collision SimpleCharacter: Don't impose a collision shape Sep 5, 2024
for label in _score_labels.values():
label.queue_free()
_score_labels.clear()

Copy link
Contributor

@starnight starnight Sep 6, 2024

Choose a reason for hiding this comment

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

This benefits from add_child().

if sprite:
sprite.queue_free()
sprite = null

Copy link
Contributor

@starnight starnight Sep 6, 2024

Choose a reason for hiding this comment

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

These benefit from add_child().

Copy link
Contributor

@starnight starnight left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM!

@starnight starnight merged commit 1fd3db8 into main Sep 6, 2024
3 checks passed
@starnight starnight deleted the no-imposed-collision branch September 6, 2024 04:02
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.

2 participants