constraining drag move along a path in iphone
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, 开发者_JAVA百科it should stop. The tracks can be any shape. What is the best appraoch..?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.
精彩评论