I have a complex issue. I am making a twister game for iOS. You can drag the arrow of the wheel with your finger. Now I wan't to make it spin when the user is swiping.
Let's say I slow spin the arrow then it should slowly move and at the end it should stop, or when the user swipes as fast as he can the arrow should spin as fast as possible.
Currently I have this code which makes the arrow draggable.
How can I do this animation?
-(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 {
}