我目前正在编写一款教育游戏,其中我需要背景不断移动。我试过使用 block (iOS 4),出于某种原因结果并不令人满意(即使我指定了线性动画,图像在最后变慢了。有什么建议吗?感谢您的帮助!
soil0 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"soil900.jpg"]];
soil0.frame = CGRectMake(0, 0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height);
[UIView animateWithDuration:5.0
delay:0.0
options:UIViewAnimationOptionRepeat | UIViewAnimationCurveLinear
animations:^{
soil0.transform = CGAffineTransformMakeTranslation(0, -450); }
completion:^(BOOL fin) { if (fin)
{
soil0.transform = CGAffineTransformMakeTranslation(0, +450);
}
}];
最佳答案
我认为您可能正在看到宽松政策。 UIViewAnimationCurveLinear
与 setAnimationCurve
类方法一起使用。尝试改用 UIViewAnimationOptionCurveLinear
。
关于objective-c - iOS 动画 : background continuously moving (game),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5045597/