views:

94

answers:

1

I am making an app in which balls roll on tracks.
So when we touch and drag the balls around the screen, they should move along the tracks. If the drag goes out too distant from the track, it should stop. The tracks can be any shape. What is the best appraoch..?

A: 

It depends on how the track is defined programatically, but it you've got a CGPath that represents it, or can make one, use can use CGPathContainsPoint in the touchesMoved method and refuse to update the position of the ball if it is outside the path.

David Kanarek