Hello all,
Is there a way to sample the color, in particular, the alpha, of a pixel of an image (PNG format), similar to,
display.colorSample( x, y, listener )?
The use case for this, is that most of my scene images (PNG) loaded via either “newImage” or “newImageRect” have many “empty” or transparent or alpha = 0, pixels. There are many overlapping smaller images (as touched players) these bigger scene images (PNG).
I do not want any “touch” or “tap” to be active on these bigger scene images, when the user touches on the “empty” or transparent part of the bigger scene images. So I would like to sample the “touch” point so to disable any “touch” action, when I detect the alpha of the pixel of the bigger scene image is 0.
My current work-around to bring the bigger scene image to “toBack()” has not worked well, as there could have multiple scene images at the same time, so the “touch” and/or “tap” has been quite confusing, when transparent part of image is touched, and the wrong image is action upon. Also, there could be many other smaller images could be behind, as they are loaded and invoked at later time.
I searched the internet, many image functions requires binding to some C libraries (like FFI and etc), but I found that Love2D has an interesting API,
r, g, b, a = ImageData:getPixel( x, y )
at https://love2d.org/wiki/ImageData:getPixel. This seems to do the work. Is there something similar for Corona?
Or is there a display object property similar to object.isHitTestable? that I could specify that only non-transparent pixels of a image (PNG) is hit testable?
Thank you.
Regards, Luan