Noticed something very peculiar. I’m created a rectangle which I place behind other stuff. I want to use the rectangle to catch tap/touch events. This is all working nice & well until I hide my rectangle with a rect.alpha = 0. My listeners stop catching the tap/touch events. When I change alpha to as little visibility as 0.1 once again listeners start functioning. Is this a known & intentional “feature” or is it a bug? Thanks.
Hi Kerem,
You need to set rect.isHitTestable = true for invisible
Cheers,
Atanas
Thanks much for that. Most appreciated.
You can also set object.isVisible = false rather than bother with setting the alpha.
I also use an invisible rectangle for detecting touches.
transRect.isVisible = false
transRect.isHitTestable = true
-Saer
Thanks much. Its all working now. I just didn’t realize alpha = 0 has this impact on objects.
I think Corona should improve on this, where an object may have a ‘bigger touch listener surface’
I am also currently drawing 2 objects; 1 is the visible object, the other is the ‘touch listener’ for the object. This is so that the touch surface is bigger than the object. Without it, it is kinda hard to trigger the touch listener. A totally waste of time and resources if you ask me…
Hi Kerem,
You need to set rect.isHitTestable = true for invisible
Cheers,
Atanas
Thanks much for that. Most appreciated.
You can also set object.isVisible = false rather than bother with setting the alpha.
I also use an invisible rectangle for detecting touches.
transRect.isVisible = false
transRect.isHitTestable = true
-Saer
Thanks much. Its all working now. I just didn’t realize alpha = 0 has this impact on objects.
I think Corona should improve on this, where an object may have a ‘bigger touch listener surface’
I am also currently drawing 2 objects; 1 is the visible object, the other is the ‘touch listener’ for the object. This is so that the touch surface is bigger than the object. Without it, it is kinda hard to trigger the touch listener. A totally waste of time and resources if you ask me…
Great info! Helped me figure out why my touch events were not registering!
Hi,
I have been using an alpha value of 0.01 to get around this as I have ‘invisible’ buttons that fade in and out of view, but are always touchable.
So, I have a question…
If you explicitly set rect.isHitTestable = true and then transition alpha up and down, making the object visible then invisible again, does it remain touchable or does transitioning the alpha back down to 0 overide the the isHitTestable attribute?
(I’d experiment with this myself, but won’t have the opportunity for some time)
Thanks,
Jules.
Great info! Helped me figure out why my touch events were not registering!
Hi,
I have been using an alpha value of 0.01 to get around this as I have ‘invisible’ buttons that fade in and out of view, but are always touchable.
So, I have a question…
If you explicitly set rect.isHitTestable = true and then transition alpha up and down, making the object visible then invisible again, does it remain touchable or does transitioning the alpha back down to 0 overide the the isHitTestable attribute?
(I’d experiment with this myself, but won’t have the opportunity for some time)
Thanks,
Jules.