Hi all you smart people out there!
I want to create a touch interface to an iOS app, that allows the user to drag an object on the screen around.
However, this object should be restricted to move along the perimeter of a circle, so that if the user is trying to drag the object outside that path, it would stick to the nearest point of that circle.
I have done some iPhone programming, but my math is poor. Please help!
Hi all you smart people out there! I want to create a touch interface
Share
All you have to do is set the frame of the view to follow the equation of a circle (of the form:
(x-a)^2 + (y-b)^2 = r^2). Once you detect the touch point, you can restrict the view’s frame according to the x or the y coordinate of the touch point (both ways are the same).EDIT- Better solution:
This can be applied similarly for
Android,Blackberry, etc too!