iphone – 我应该如何在iOS中动画200多张图片?

iphone – 我应该如何在iOS中动画200多张图片?,第1张

概述我有超过200张图像,我想在大约10秒的空间内制作动画.我尝试通过将图像加载到数组中然后调用startAnimating方法来使用animation Images.这在模拟器中运行正常但是撞毁了iPad. 我曾尝试每隔1/25秒调用一次NStimer,并在每次定时器触发时更改图像.这比以前的方法表现更好,它在模拟器中运行良好,但在iPad的(滞后)动画结束时也崩溃了. 有人可以帮助我,告诉我解决这 我有超过200张图像,我想在大约10秒的空间内制作动画.我尝试通过将图像加载到数组中然后调用startAnimating方法来使用animation Images.这在模拟器中运行正常但是撞毁了iPad.

我曾尝试每隔1/25秒调用一次NStimer,并在每次定时器触发时更改图像.这比以前的方法表现更好,它在模拟器中运行良好,但在iPad的(滞后)动画结束时也崩溃了.

有人可以帮助我,告诉我解决这个问题的理想方法吗?谢谢.

原始代码:

- (voID) humptyFallingAnim {    Nsstring *filename;    if (humptyImageCounter < 285) {        filename = [Nsstring stringWithFormat:@"Humpty Animation HD1.2 png sequence/humpty_HD1.2_%d.png",humptyImageCounter];            UIImage *someImage = [UIImage imagenamed:filename];            humptyFalling.image = someImage;            NSLog(@"loaded image: %d",humptyImageCounter);        humptyImageCounter++;    } else {        NSLog(@"Timer invalIDated");        [humptyTimer invalIDate];        humptyTimer = nil;    }}

编辑:一些不适合我的新代码

Nsstring *filename;    if (humptyImageCounter < 285) {        filename = [Nsstring stringWithFormat:@"Humpty Animation HD1.2 png sequence/humpty_HD1.2_%d.png",humptyImageCounter];        @autoreleasepool {            UIImage *someImage = [UIImage imageWithContentsOffile:filename];            humptyFalling.image = someImage;            NSLog(@"loaded image: %d",humptyImageCounter);        }        humptyImageCounter++;    } else {        NSLog(@"Timer invalIDated");        [humptyTimer invalIDate];        humptyTimer = nil;    }

编辑2:

-(voID) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {    NSLog(@"You shook it!");    [self.vIEw bringSubvIEwToFront:imgSnail];    if (deviceHasBeenShaken == 0) {        deviceHasBeenShaken = 1;    }    humptyTimer = [NSTimer scheduledTimerWithTimeInterval:(1/25) target:self selector:@selector(humptyFallingAnim) userInfo:nil repeats:YES];    [self moveHumptyposition];}
解决方法 不幸的是,这听起来像OpenGL ES的工作.应用程序是游戏吗? 总结

以上是内存溢出为你收集整理的iphone – 我应该如何在iOS中动画200多张图片?全部内容,希望文章能够帮你解决iphone – 我应该如何在iOS中动画200多张图片?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1081284.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存