Using image file as button with transparency

All other topics about Ventuz here.

Using image file as button with transparency

Postby spikylaura » 16 Dec 2013, 16:24

Hi all,

I am trying to work out a way to use an image file with alpha as a button, that only triggers when you click on a visible (non-alpha) pixel. Any help gratefully received!

Many thanks

Paul
spikylaura
 
Posts: 28
Joined: 26 Jan 2012, 11:53

Re: Using image file as button with transparency

Postby Alex Klein » 17 Dec 2013, 11:28

Hi Paul,

in general, it is often advisable to use hit targets that are simpler than the actual shape/texture/... For example, if you have an icon that shows an "O", it's usually a bad idea to just accept the pixels occupied by the pencil as hit targets because the user might accidentally hit the gap. So for that "O", I would use a bigger rectangle. Especially for touch, hit surfaces have to be quite large...

That aside, if you really want to hit though the transparent pixel, you'll have to build a geometry that has holes there and use that as a touch proxy (so have a rectangle that draws your texture without a touch node in front of it and have an invisible, more detailed mesh on top that has the holes). The touch subsystem does a ray-triangle intersection test and does not use the actual pixels rendered on screen.

Alex
Alex Klein
 


Return to General Discussion

cron