Hittest against polygon or transparent image?

Hi Corona developers,

I have many draggable objects, they are non-rectangular. What is the best way to touch and drag (hitTestPoint?) those non-rectangular objects. This is not physics based but if that is the only way let me know. What I did in Flash is rough-trace my transparent images and use that polygon as the hitArea. How would I do that in Corona?

Thanks!

You are a Flash developer, so you can use math to determine if a point is in a polygon. You can still have an overlay area that has the alpha property of 0.01 to emit touch events.

cheers,

?:)

Hi thanks very much. What do you mean by overlay area with an alpha property of 0.01? My sprite is transparent, a triangular shape, with transparency, the touch events go to the bounding box only, so it seems alpha has no effect on the hit area. Sorry I'm a newbie :)

your image is transparent, I understand, however the boundingbox for hitText is the rectangular area, not the non-transparent area.

Now if you were creating a boundingBox that was a primitive then you could be using a roundedrect, or a circle, etc which you can set the alpha to 0.01 this overlays onto your graphic and handles the touch events rather than your image.

You will understand this the more you play around with CoronaSDK.

cheers,

?:)

Ok but rectangles and circles are not an option in my case. So it seems like I won't be able to use polygons or image transparency for hit areas. Thanks!

views:1918 update:2011/10/25 9:10:48
corona forums © 2003-2011