我需要让这个动画从左到右连续运行。现在正在运行,但仅显示 1 次(加载游戏时)。我想让这个动画连续运行,从左到右连续运行。定时器和速度已经在工作。这是我当前的代码:
- (void)airplane1Code {
airplane1.center = CGPointMake(airplane1.center.x + 10, airplane1.center.y);
}
有什么建议吗?谢谢
最佳答案
您可以使用 UIViewAnimationOptionRepeat 创建 UIView 动画
airplane1.center = CGPointMake(startX, startY);
[UIView animateWithDuration:10.0 //10seconds
delay: 0
options: UIViewAnimationOptionRepeat
animations:^{
airplane1.center = CGPointMake(endX, endY);
}
completion:nil];
这将使它从头到尾一遍又一遍地执行相同的动画。为了停止动画,调用
[airplane1.layer removeAllAnimations];
关于ios - 连续从左向右移动图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22211796/