我正在制作一个游戏,目前我的“玩家”正在按照我所实现的方式进行动画处理(目前这是错误的),并且它从头到尾不断地运行动画,因为当函数执行时它总是从头开始重新启动叫。防止这种情况并让动画一直运行的最佳方法是什么?这是我目前正在使用的代码:
- (void) startAnimatingLeft
{
NSArray *images = [NSArray arrayWithObjects:img9,img10,img11,img12,img13,img14,img15,img16, nil];
[imageView setAnimationImages:images];
[imageView startAnimating];
animateTimer = [NSTimer scheduledTimerWithTimeInterval:0.6 target:self selector:@selector(nothingMovingLeft) userInfo:nil repeats:NO];
}
最佳答案
startAnimating
This method always starts the animation from the first image in the list.
因此,如果图像已经处于动画状态,则不应调用此方法。您可以调用 isAnimating
方法来检查图像是否有动画。
关于iphone - 如何防止 UIImage 不断重放动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15508323/