当我旋转踏板时,我正在尝试旋转自行车车轮。
当我逆时针旋转时,没有问题。
但是当我顺时针旋转大约 2-3 秒时,图像开始以快速逆时针旋转。
当我尝试记录 angleInRadians 值时:逆时针旋转时,angleInRadians 值最多从 -0.05 变化到 -0.1。angleInRadians 值在开始时将在 0.05 到 0.1 之间,但突然值变为 -6.1,-6.2 类似的值。请参阅下面的日志。
我改变了图像的锚点。我不确定这是否重要。
对不起我的英语和格式不好
- (void) viewDidLoad
{
[super viewDidLoad];
self.PedalTurn.layer.anchorPoint = CGPointMake(0.5, 0.6);
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint center = CGPointMake(CGRectGetMidX(self.PedalTurn.bounds), CGRectGetMidY(self.PedalTurn.bounds));
CGPoint currentPoint = [touch locationInView:self.PedalTurn];
CGPoint previousPoint = [touch previousLocationInView:self.PedalTurn];
CGFloat angleInRadians = atan2f(currentPoint.y - center.y, currentPoint.x - center.x) - atan2f(previousPoint.y - center.y, previousPoint.x - center.x);
self.PedalTurn.transform = CGAffineTransformRotate(self.PedalTurn.transform, angleInRadians);
}
Angle in radians: 0.110071
Angle in radians: 0.0984247
Angle in radians: 0.107355
Angle in radians: 0.118767
Angle in radians: 0.121201
Angle in radians: 0.112823
Angle in radians: 0.0899732
Angle in radians: 0.0883234
Angle in radians: 0.105448
Angle in radians: 0.0884745
Angle in radians: 0.0983613
Angle in radians: 0.108684
Angle in radians: 0.119307
Angle in radians: 0.108768
Angle in radians: 0.111302
Angle in radians: 0.145414
Angle in radians: -6.14848
Angle in radians: -6.13048
Angle in radians: -6.12109
Angle in radians: -6.14578
Angle in radians: -6.13917
Angle in radians: -6.11675
Angle in radians: -6.13025
Angle in radians: -6.15015
Angle in radians: -6.14989
Angle in radians: -6.15097
Angle in radians: -6.14732
Angle in radians: -6.15547
Angle in radians: -6.136
Angle in radians: -6.13241