你可以设置一个名为“lastPoint”的成员变量来记录点你感动
的,你可以calc下下一次的方向
CGPoint lastPoint;
- (void) touchedBegin:(NSSet *)touches withEvent:(UIEvent *)event {
lastPoint = [touch locationInView:self.view];
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
//you can save the point , then used in next time you want
int tInput = [allTouches count]-1;
UITouch *touch =[[allTouches allObjects] objectAtIndex:tInput];
CGPoint location = [touch locationInView:self.view];
float theAngle = atan2(location.y-imageX.center.y, location.x-imageX.center.x);
float theLastAngle = atan2(lastPoint.y-imageX.center.y, lastPoint.x-imageX.center.x);
lastPoint = location;
// compare theAngle & theLastAngle , so you can know it is clockwise or counterclockwise.
}
我没仔细看过那个帖子最后一次,但我注意到接受的答案计算了fromAngle和toAngle。这些差异的迹象似乎是你需要的。 – danh 2012-04-18 00:48:55
这不起作用。在一个圆圈内,你不能依靠角度来看物体旋转的方向,这意味着如果我将物体从270度旋转到270度,我怎么知道我旋转物体的方式? – 2012-04-18 01:24:58