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

Rework on the FlxNestedSprite #381

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Cheemsandfriends
Copy link

While I was using FlxNestedSprite for a project, I noticed that it was very... uncomfortable
for example, you would need to use a relative variable, which you would use in case you added a child, making it very difficult to do stuff like sprite.setPosition() or even sprite.x! but instead sprite.relativeX. same goes with acceleration, scale, etc.

This should fix the inconvenience.

@Geokureli
Copy link
Member

Geokureli commented Jul 27, 2023

I'm also very confused on how the updateMotion() call was removed and seemingly not put anywhere else.

still confused about this

@Cheemsandfriends
Copy link
Author

Can you type out examples of how things were done in the old code vs the new way?

Basically, when using FlxNestedSprite, if you added to a parent, the x value would be overriden by the parent position. same goes for alpha, angle, velocity, etc, etc...

With this, what it does is basically if the instance's a child, it would be concating the parent's "relativeMatrix" which would concat the grandparent's matrix and so forth until the beginning of its family tree lmao.

so in the old code, you would need to set relativeX to set the child's position, in the new one, you can do it directly with x. same goes for angle, every type of velocity and so on.

same goes with the color transform, so you can tint the sprite via color, put it inside a parent, and then it would be the tint + the parent's tint with relativeColorTransform.

@itulau
Copy link
Contributor

itulau commented Dec 19, 2023

I've tested your changes and my sprite just went flying off the screen:

Screencast from 18-12-23 23 35 23

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.

None yet

3 participants