event listener on image exclude transparent part

Hello,

I want make my image not touchable only on the transparency part.

The solution is to use mask. But it’s horrible to use them. It’s hard to generate mask, we can’t use imagesheet, it’s take time to use imageSuffix…

Someone has another solution? :slight_smile:

It’s for this handsome game we are working on

Thank you in advance

Someone have a solution?

Drop a display.newRect() on top of the sprite, make it invisible and .isHitTestable = true. Put them both in a group and always move the group. Put your touch listener on the rectangle.

That should work for you.

Good idea I will try it :slight_smile: Thank you

Generating masks is real easy if you have photoshop.  I have a batch script that generates all my 2bit masks from 32bit graphics.  The problem with floating a rect over your graphic is you will still get touch events on your transparent areas.  Masking is the only way to go (apart from having a polygon that roughly matches your asset which is a major pain!)

I wish Corona supported masks for image sheets - that would be a major bonus.

Someone have a solution?

Drop a display.newRect() on top of the sprite, make it invisible and .isHitTestable = true. Put them both in a group and always move the group. Put your touch listener on the rectangle.

That should work for you.

Good idea I will try it :slight_smile: Thank you

Generating masks is real easy if you have photoshop.  I have a batch script that generates all my 2bit masks from 32bit graphics.  The problem with floating a rect over your graphic is you will still get touch events on your transparent areas.  Masking is the only way to go (apart from having a polygon that roughly matches your asset which is a major pain!)

I wish Corona supported masks for image sheets - that would be a major bonus.