我正在制作一个摆锤动画,它从0度摆到最大200度,然后再回来。问题是,如果摆锤超过了180度,它会通过继续顺时针方向返回到0度。而我希望它逆时针旋转。以下是我的代码:
('right' 是一个布尔值,当摆锤从左到右摆动时为TRUE)
有什么办法可以让这个工作?它是我摆动计谋的最后一块拼图,除此之外一切都运作良好:D 谢谢! 迈克尔
- (void)swingPendulum {
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
if (right)
rotationAnimation.toValue = [NSNumber numberWithFloat:degreesToRadians(kMax)];
else
rotationAnimation.toValue = [NSNumber numberWithFloat:degreesToRadians(kMin)];
rotationAnimation.duration = 1.0;
rotationAnimation.repeatCount = 1.0;
rotationAnimation.delegate = self;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
rotationAnimation.removedOnCompletion = NO;
[pendulum.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
有什么办法可以让这个工作?它是我摆动计谋的最后一块拼图,除此之外一切都运作良好:D 谢谢! 迈克尔