开发者

constraining drag move along a path in iphone

开发者 https://www.devze.com 2022-12-12 18:55 出处:网络
I am making an appin which balls roll on tracks. So when we touch and drag the balls around the screen, they should move alongthe tracks. If the drag goes out toodistant from the track, 开发者_JAVA百科

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消