Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

event listener on image exclude transparent part
Started by remiduchalard Mar 13 2017 01:37 AM

4 replies to this topic
mask alpha png
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

remiduchalard

[GLOBAL: userInfoPane.html]
remiduchalard
  • Contributor

  • 194 posts
  • Corona SDK

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? :)

It's for this handsome game we are working on

 

Thank you in advance



[TOPIC: post.html]
#2

remiduchalard

[GLOBAL: userInfoPane.html]
remiduchalard
  • Contributor

  • 194 posts
  • Corona SDK

Someone have a solution?



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 22,306 posts
  • Corona Staff

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.



[TOPIC: post.html]
#4

remiduchalard

[GLOBAL: userInfoPane.html]
remiduchalard
  • Contributor

  • 194 posts
  • Corona SDK

Good idea I will try it :) Thank you



[TOPIC: post.html]
#5

Sphere Game Studios

[GLOBAL: userInfoPane.html]
Sphere Game Studios
  • Corona Geek

  • 1,276 posts
  • Corona SDK

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.




[topic_controls]
[/topic_controls]