沿iphone路径约束拖累招 [英] constraining drag move along a path in iphone

查看:141
本文介绍了沿iphone路径约束拖累招的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在在球上的轨道滚动的应用程序。结果
所以,当我们触摸并拖动屏幕周围的球,他们应该沿着轨道移动。如果拖动从轨道出门不远,就应该停止。轨道可以是任何形状。
什么是最好的appraoch ..?

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..?

推荐答案

这取决于如何轨道定义编程,但你已经有了一个CGPath的重新presents,或者可以做一个,可以使用在touchesMoved方法使用CGPathContainsPoint并拒绝更新球的位置,如果它是路径之外。

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.

这篇关于沿iphone路径约束拖累招的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆