我曾尝试每隔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多张图片?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)