I have a physics body made from an image. I then add a couple of shapes to the body which correspond with the image.
If I do this:
thing = display.newImage( "thing.png" )
physics.addBody( thing, shape1, shape2 ) -- abbreviated
thing:addEventListener( "tap", onTap )
then the “taps” are detected within the bounds of the image rectangle and not the shape(s) of the body.
How do I detect taps only on some/all of the shapes? [import]uid: 8353 topic_id: 3413 reply_id: 303413[/import]
emf715
2
I’m bumping this really old thread, as this same issue is causing me huge headaches.
Any advice from Ansca on this bug?
[import]uid: 13529 topic_id: 3413 reply_id: 28168[/import]
jmp909
3
your syntax is wrong for a start
[lua]-- For a complex body (multiple body elements)
physics.addBody(object, [bodyType,]
{density=d1, friction=f1, bounce=b1, shape=s1},
{density=d2, friction=f2, bounce=b2, shape=s2},
{density=d3, friction=f3, bounce=b3, shape=s3}
)[/lua]
[import]uid: 6645 topic_id: 3413 reply_id: 28181[/import]
emf715
4
That’s not the issue. Even if you create a round physics body and use radius, the image’s bounding rectangle still responds to touch events.
Thanks for the suggestion though. [import]uid: 13529 topic_id: 3413 reply_id: 28182[/import]
jmp909
5
ah yes that’s in the bug forum already [import]uid: 6645 topic_id: 3413 reply_id: 28234[/import]