我有一个复杂的问题。我正在为 iOS 制作一个旋风游戏。您可以用手指拖动滚轮的箭头。现在我不想让它在用户滑动时旋转。
假设我慢速旋转箭头,然后它应该慢慢移动,最后它应该停止,或者当用户尽可能快地滑动时,箭头应该尽可能快地旋转。
目前我有这段代码可以使箭头可拖动。
我该怎么做这个动画?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self.view];
CGPoint startPoint = CGPointMake(arrowImage.center.x, arrowImage.center.y);
CGPoint endPoint = CGPointMake(gestureStartPoint.x, gestureStartPoint.y);
angleStartVal = ((((atan2((endPoint.y - startPoint.y) , (endPoint.x - startPoint.x)))*180)/M_PI)+90);
timerStart = CFAbsoluteTimeGetCurrent();
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
CGPoint startPoint = CGPointMake(arrowImage.center.x, arrowImage.center.y);
CGPoint endPoint = CGPointMake(currentPosition.x, currentPosition.y);
angleVal = ((((atan2((endPoint.y - startPoint.y) , (endPoint.x - startPoint.x)))*180)/M_PI)+90);
arrowImage.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(angleVal));
//NSLog(@"angle: %f",angleVal);
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}