Hi guys,
I guess most of us use Sprite:hitTestPoint() for testing wether some mouse/touch event is inside the rectangular area of a given sprite. Now that you can clip() a sprite, I was wondering if hitTestPoint should also take clipping and visibility into account, i.e. return false when the coordinates are clipped-out or if the sprite was "setVisible(false)".
What do you think ? Do some of you use hitTestPoint for some other matter that would be broken up by such changes ?
Obviously setClip is quite recent so I don't believe it would harm to check for it, but I am not so sure about setVisible()..
Comments
real problem will be when we will have masking, then you will need to check alpha value too
But what about sprite visibility ? Should a sprite that has been made hidden through Sprite:setVisible(false) responds systematically false to hitTestPoint, or current behavior is the good one (visibility ignored) ?
while the other direction won't be possible.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I suppose it could be useful to keep it this way (visibility ignored) to have a chance of using "invisible buttons", but maybe that could be achieved either setting their alpha to 0.
I agree hitTestPoint should take into account setClip bounds though, and maybe it could be useful to allow query on both sizes: "clipped" and "original", not that I know I will need it... but who knows?
thank you for your work! ^:)^
So all current implementations would work as is and does not break backwards compatibility
Likes: pie, keszegh, hgy29
The main idea is to provide a way to ignore transparent parts of a sprite, but doing so may become CPU and/or GPU intensive. Perhaps we could allow to pass a bounding shape to hitTestPoint(), to further reduce the active area of a Sprite. Or perform a texture lookup to check for transparent areas (for bitmaps only)...
Take clip into account is very good.
I myself always use more area than just the visible part, so i can make sure it can be touched even if they did not precisely touching it.
https://deluxepixel.com