tap/touch detection empty space

There are some areas of “empty space” where I need a tap detection to occur. I placed an object there with the intention of making it invisible (alpha = 0).

I can make it work by putting an alpha of 0.01 (which looks invisible on the Corona Simulator). But as soon as I put the alpha to 0, tap detection no longer works.

Is that normal? And is there a more elegant way than an alpha of 0.01 to make it invisible yet detectable?

You can use that 0.01 alpha trick, or you can set object.isHitTestable = true and then you can also touch fully invisible objects.

I use a newImageRect() with a transparent texture.

I keep two textures in all my projects:

  • fillT.png  - 16x16 transparent texture (for this and other purposes)
  • fillW.png - 16x16 white texture.

just a rect with .isVisible=false and .isHitTestable=true – far less load on the GPU than rendering full-screen alpha (from either source, ie .alpha=0.01 or RGBA=???0)

You can use that 0.01 alpha trick, or you can set object.isHitTestable = true and then you can also touch fully invisible objects.

I use a newImageRect() with a transparent texture.

I keep two textures in all my projects:

  • fillT.png  - 16x16 transparent texture (for this and other purposes)
  • fillW.png - 16x16 white texture.

just a rect with .isVisible=false and .isHitTestable=true – far less load on the GPU than rendering full-screen alpha (from either source, ie .alpha=0.01 or RGBA=???0)