flixel icon indicating copy to clipboard operation
flixel copied to clipboard

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

Open DetectiveBaldi opened this issue 1 year ago • 4 comments

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.

DetectiveBaldi avatar Jun 03 '24 05:06 DetectiveBaldi

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 avatar Jun 03 '24 13:06 Geokureli

@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

Geokureli avatar Aug 07 '24 16:08 Geokureli

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

DetectiveBaldi avatar Sep 23 '24 23:09 DetectiveBaldi

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

Geokureli avatar Sep 24 '24 15:09 Geokureli