如何开发“旋转瓶子”应用程序

时间:2012-03-07 04:11:31

标签: ios uigesturerecognizer

我正在开瓶游戏。我无法弄清楚如何通过滑动手指的速度来控制瓶子的旋转速度。我希望它像命运之轮一样工作,你刷的速度越快就越快。

我开始使用UIRotationGestureRecognizer开发,但我真的不认为这是最好的方法。

2 个答案:

答案 0 :(得分:7)

嘿检查this demo

您必须计算velocity。这取决于touchesMoved:withEvent:touchesEnded:withEvent:


这也是有用的链接:iphone development - UIRotationGestureRecognizer (Clockwise & counter Clockwise detection)?

答案 1 :(得分:0)

使用touchesBegan:withEvent:touchesEnded:withEvent:直接检测点击事件,而不是UIRotationGestureRecognizer。

存储触摸开始的时间和位置,然后当用户结束触摸时计算移动时移动的距离并将其除以获得手指移动速度所需的时间。

然后相应地旋转你的瓶子。