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

Feature idea: auto-create Sprite bounds #12

Open
JoeStrout opened this issue Nov 1, 2023 · 1 comment
Open

Feature idea: auto-create Sprite bounds #12

JoeStrout opened this issue Nov 1, 2023 · 1 comment

Comments

@JoeStrout
Copy link
Owner

Right now, whenever you want a sprite that can do any sort of hit-testing, you have to (1) create a new Bounds and assign to localBounds, (2) assign its width and height (almost always from the image width and height).

It'd be nice to make life easier for the simple and common case, by automatically instantiating this localBounds as soon as you do any operation on the sprite that implies the need for one. So, as soon as you call contains, overlaps , worldBounds, corners, or setCorners; or use it as the argument to some other contains call.

When any of these things happen, if localBounds is null, then initialize it to a new Bounds set to match the current image of the sprite.

@juh9870
Copy link

juh9870 commented Nov 1, 2023

Alternative idea is for localBounds to be a function on a sprite, that will replace self.localBounds with an actual bounds

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

No branches or pull requests

2 participants