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

Detect changes to clipRect without needing to reset the field in order to take effect #3162

Open
DetectiveBaldi opened this issue Jun 3, 2024 · 4 comments

Comments

@DetectiveBaldi
Copy link
Contributor

currently, using FlxRect for fields such as FlxSprite.clipRect requires reassigning in order for changes to take effect. i've seen multiple people question this, and i've wondered if there's a simpler way around it.

Some ideas:

  • Create a class similar to FlxCallbackPoint (potentially FlxCallbackRect) that acts similarly to the callback point class.
  • Implement this functionality in FlxRect itself, possibly a callback function that gets called when setting x, y, width, height.

If we went with the latter, we could potentially remove FlxCallbackPoint and add similar functionality into the standard FlxPoint class.

@Geokureli Geokureli changed the title Add set callbacks to FlxRect Detect changes to clipRect without needing to reset the field in order to take effect Jun 3, 2024
@Geokureli
Copy link
Member

As I said in chat, I'm not a fan of FlxCallbackPoints for memory reasons and I'm even trying to do away with that in the long run. but I think there may be another way to detect changes to the clipRect field, i'll do some test when I have time

@Geokureli
Copy link
Member

@Sword352 had an idea of polling the current cliprect in draw() (and all other places) rather than triggering some refresh on change or detecting changes. I think this would work for actually rendering the sprite but fear it may make other affected getters more costly. Its worth consideration, nonetheless

@DetectiveBaldi
Copy link
Contributor Author

As I said in chat, I'm not a fan of FlxCallbackPoints for memory reasons and I'm even trying to do away with that in the long run. but I think there may be another way to detect changes to the clipRect field, i'll do some test when I have time

a "bit" late but do you mind sharing the idea you had in mind? depending on what it is i could attempt implementation and appropriate testing

@Geokureli
Copy link
Member

Geokureli commented Sep 24, 2024

When I have time, I'll make a quick mock-up of what I have in mind, thanks for reminding me

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