iphone - 如何防止 UIImage 不断重放动画

标签 iphone ios objective-c macos 2d-games

我正在制作一个游戏,目前我的“玩家”正在按照我所实现的方式进行动画处理(目前这是错误的),并且它从头到尾不断地运行动画,因为当函数执行时它总是从头开始重新启动叫。防止这种情况并让动画一直运行的最佳方法是什么?这是我目前正在使用的代码:

- (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];
}

最佳答案

来自UIImage documentation :

startAnimating

This method always starts the animation from the first image in the list.

因此,如果图像已经处于动画状态,则不应调用此方法。您可以调用 isAnimating 方法来检查图像是否有动画。

关于iphone - 如何防止 UIImage 不断重放动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15508323/

相关文章:

ios - UIImagePickerController 在相机胶卷中打开

ios - Swift:向下滚动时下拉溢出消失

ios - 使用 SLComposeViewController 将图像发布到 Facebook

ios - xcode - 从 TableView 中删除一行

ios - iPhone 中的 mstreamd 是什么

iphone - iPhone 游戏可以在线玩吗?

iphone - 对 NSUserDefaults 进行数学运算并重新保存 - 不起作用

ios - 为 objective-c 麦克风检测添加动画

ios - 获取 UILabel 中的每一行文本

objective-c - 如何创建自定义 NSStepper 和 NSTabView