I have button imagery integrated into my background pic, and then overlay this with far larger areas to allow players to slightly miss the buttons.
So I want these area objects to receive touch events but not show. How do I do this? Setting isHitTestable to true and isVisible to false will still show the objects… is that a bug or am I doing it wrong?
As a workaround I’m setting a really low alpha value right now, but that’s not a nice workaround and might even affect speed…
This isn’t a confirmed answer, but I believe that setting “alpha=0.0” and “isHitTestable=true” shouldn’t slow down performance at all. I think the OpenGL engine effectively ignores rendering of any Corona object with alpha of 0.0 (as it logically should, since the user can’t see it).
Can anybody confirm this? I have at least one object in my own game that is hit-testable but also invisible (using “alpha=0.0”, not “setVisible=false”). If I recall, using “setVisible=false” in conjunction with “isHitTestable” (as Philipp points out) makes the object become visible again… that is why I set the alpha to 0.
Brent, thanks, that seems to work as workaround! I had previously try to set an object to zero alpha but it was removed from receiving touches, but in combination with setting isHitTestable to true it seems to work now. Guess it’s a bug but that looks like a feasible workaround. I hope it doesn’t cause lags [import]uid: 10284 topic_id: 4519 reply_id: 14336[/import]
You’re right. There is a bug with isHitTestable, and we’re aware of it. Using it causes objects to become visible. We have bug #1807 filed internally. We’ll let you know when it’s fixed.
[import]uid: 5917 topic_id: 4519 reply_id: 15634[/import]
If my tests aren’t fooling me then this has indeed been fixed a while ago – I was able to remove all my workarounds from the code, it automatically worked as expected now (on both Mac simulator and iPad, haven’t checked elsewhere). [import]uid: 10284 topic_id: 4519 reply_id: 24591[/import]
On my Mac (which I believe has latest production build which is now a couple of months old) the bug still exists.
I spent all day Saturday trying to figure out what was wrong with my code, finally in frustration I replaced the isVisible’s with alpha’s to work around the problem. [import]uid: 5178 topic_id: 4519 reply_id: 24602[/import]