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

Make sprite position getters more effecient #318

Open
quinton-ashley opened this issue Apr 7, 2024 · 0 comments
Open

Make sprite position getters more effecient #318

quinton-ashley opened this issue Apr 7, 2024 · 0 comments
Assignees

Comments

@quinton-ashley
Copy link
Owner

quinton-ashley commented Apr 7, 2024

@codingMASTER398 noticed that sprite.x and sprite.y getters are inefficient with sprites that have physics fixtures because every time they're used, p5play recalculates the sprite's position, converting from meters to pixels. Yet, this calculation only needs to be done if sprite.body.getPosition() changes.

Perhaps one day this could be done with Signals:
https://www.youtube.com/watch?v=JvE_xQVIFF0

But it could presently be done by with boolean flags that store whether the sprite's position was changed either by the user or world.step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant