zakari
zakari

Reputation: 3

touched Image and recovering the touched point's coordinate

I'm working on an iPad application and that's my problem: I elaborated an algorithm to know if a point is inside a polygon, in an image. So I need when touching the Image, to know the coordinates of the touched point and then do an action using those coordinates (an NSLog to make the example easy), the problem is that I can't use an IBAction on an UIImageView, and so can't recover the point's coordinates. Thanks for any help

Upvotes: 0

Views: 107

Answers (1)

Feel Physics
Feel Physics

Reputation: 2783

I think at first you have to make polygon which fit to your image. And then you can use touchesBegan:withEvent: to get the coordinate of touch point and judge whether the point is inside of polygon or not.

Here is similar question like yours.

How to get particular touch Area?

I think this is a little difficult work, so maybe you would better use cocos2d library which have collision judgement function.

image

http://box2d.org/forum/viewtopic.php?f=9&t=7487

But also I think iOS is well constructed for handling touch, so this is beneficial effort for you.

Upvotes: 1

Related Questions