Skip to content
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

FlxNapeSprite: add support for compound bodies #243

Closed
wants to merge 3 commits into from

Conversation

thegoodideaco
Copy link

If the body is part of a compound, then it's space cannot be changed, instead must be added/removed from the compound bodies list

If the body is part of a compound, then it's space cannot be changed, instead must be added/removed from the compound bodies list
@@ -95,6 +95,7 @@ class FlxNapeSprite extends FlxSprite
}

/**
/**
Copy link
Member

Choose a reason for hiding this comment

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

Seems the /** here was duplicated?

Copy link
Author

Choose a reason for hiding this comment

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

ahh crap, fixing

@Gama11
Copy link
Member

Gama11 commented Mar 28, 2016

Any nape demo or code I could use to test this with?

@thegoodideaco
Copy link
Author

I can make a quick example if you like.

@@ -116,10 +121,14 @@ class FlxNapeSprite extends FlxSprite
{
super.revive();

if (body != null)
if (body != null && body.compound == null)
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure it shouldn't look like this?

if (body != null)
{
    if (body.compound == null)
        body.space = FlxNapeSpace.space;
    else
        body.compound.bodies.add(body);
}

Right now it would add null to compound.bodies.

Added support for compound bodies
@thegoodideaco
Copy link
Author

@Gama11
Copy link
Member

Gama11 commented Mar 29, 2016

Thanks!

set_physicsEnabled() can still cause a crash. Should probably move the logic for adding a body / removing a body into separate methods to avoid redundancy and to be usable from there.

@Gama11 Gama11 changed the title Update FlxNapeSprite.hx FlxNapeSprite: add support for compound bodies Mar 31, 2016
@Gama11
Copy link
Member

Gama11 commented Apr 2, 2016

Any update? :)

@thegoodideaco
Copy link
Author

Should be ready to rock

c.active = false;
});

if (body.compound == null)
Copy link
Member

Choose a reason for hiding this comment

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

This code section looks like an exact copy of the one in revive().

@Gama11
Copy link
Member

Gama11 commented Apr 21, 2016

The most recent commit doesn't seem to have any impact on the set_physEnabled crash:

Error: Cannot set the space of a Body belonging to a Compound, only the root Compound space can be set

(see https://github.com/Gama11/FlxNapeSpriteTest)

@thegoodideaco
Copy link
Author

This is odd, let me look

@thegoodideaco
Copy link
Author

i think we need to add an additional property to store any compound it might be apart of. If we disable physics, we have to remove it from the compound instead of from space. We need something to reference if they enable physics again

@Gama11
Copy link
Member

Gama11 commented Apr 21, 2016

Hm... this is getting pretty complex. I should finally get around to setting up unit tests for flixel-addons so we can test all these different cases..

@thegoodideaco
Copy link
Author

I agree

@Gama11
Copy link
Member

Gama11 commented Jun 25, 2018

Closing this for now since there's still some unresolved issues, I created an issue as a reminder: #321

@Gama11 Gama11 closed this Jun 25, 2018
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