Touch events and transparency

Is there a way to have touch events “fall through” transparent parts of objects? Right now they follow the shape (usually rectangular) of objects/images, which means they might get caught by the blank space surrounding or in the corners of your actual image.

The only way I can think of to approximate this right now would be to use PhysicsEditor to help create a matching physics body, making it a sensor, and creating objects when a touch happens to see if there are physics collisions. A little over-the-top, to say the least.

Anyone have better suggestions? [import]uid: 35852 topic_id: 8273 reply_id: 308273[/import]

If you’ve only tested in the simulator then bear in mind that fingers are a lot less accurate than a mouse pointer. People tapping on device won’t notice this. [import]uid: 12108 topic_id: 8273 reply_id: 29529[/import]

Yes, most of the time that wouldn’t be a real noticeable problem. My problem comes when I have relatively large images where the differences between the roundish object and square rectangle of the image are very obvious.

The other case is that I have some images with a significant amount of transparency surrounding a small amount of content - for reasons of ease of alignment. Which also has me wondering - is that a really bad way of doing things texture-memory-wise? [import]uid: 35852 topic_id: 8273 reply_id: 29533[/import]

I’ve decided to simply implement an approximate touch area using a number of circles.

And as for images with large amounts of transparency, I tested it and yes, it turns out to be a very bad practice texture-memory-wise since the texture memory consumed is still directly correlated to the size of the whole image, even when the .png is tiny. [import]uid: 35852 topic_id: 8273 reply_id: 29534[/import]

hm, I can’t think of an easy solution for that problem. The approach I would take is overlay a bunch of small invisible rectangles and detect touches on those rather than the big round object.

is that a really bad way of doing things texture-memory-wise?

Yes. All those transparent pixels are still taking up room on the videocard. [import]uid: 12108 topic_id: 8273 reply_id: 29535[/import]

Looks like I sent my last post just before you did! Thanks for the help, jhocking.

I’ve tried using circles and it works great since the drawn vector circles detect touches correctly and it is pretty easy to approximate a big roundish shape using just a few of them.

Thanks! [import]uid: 35852 topic_id: 8273 reply_id: 29537[/import]

I hope the Ansca guys are reading this post and are planning to implement a solution for this issue. That is have the option to have invisible pixels not dispatch touch events or have the touch event identify if it has touched an invisible pixel.

I’ve run into the same issue with object selection in my iso engine. It’s impractical to create invisible collision boundaries for all your interactive sprites. It’s better to have greater precision and then have the option to create the collision boundary to make things easier to select than vice versa. [import]uid: 27183 topic_id: 8273 reply_id: 29729[/import]

+1 [import]uid: 10426 topic_id: 8273 reply_id: 29761[/import]