Bra*_*ker 4 iphone animation uiimageview ipad ios
目前我在计时器上有一个PNG动画,每隔0.01秒就会发射一次.但是,性能不是最佳的,动画明显很慢.我有超过2000张图片.有没有更好的方法来实现这一目标?我发布了类似于下面的方法.
timer_ = [NSTimer scheduledTimerWithTimeInterval:.01 target:self
selector:@selector(switchImage) userInfo:nil repeats:YES];
-(void)switchImage
{
p = [p stringByAppendingFormat:@"/Movie Clipping 1 000%i.png",i];
imageView_.image = [UIImage imageWithContentsOfFile:p];
i = i++;
}
Run Code Online (Sandbox Code Playgroud)
您的PNG究竟是什么尺寸(我的意思是KB以及确切的像素大小)?
我们在这方面已经做了很多工作,并且可以毫不费力地播放动画片,大约500x500.所以我只是想知道,谢谢.
一个直接的问题是你试图以100hz运行,每秒100次??!
这绝对不可能.没有任何东西以100 fps运行.20fps是"非常平滑",30fps是"令人难以置信的平滑",40fps是"令人难以置信的人类视觉 - 研究水平如果能够实现平滑"并且无法实现100 fps.
这与OpenGLES完全没有任何关系.
普通环境会很快为您加载帧.
所以首先回到30 fps(最多!)并扔掉每个第2和第3个图像,这样动画看起来一样.即,"i = i ++"在您的代码行中变为"i + = 3".
这可能是破坏你努力的压倒性问题!
下一个问题!如果你按照这样的方式加载每个图像,你几乎肯定需要随意释放它们,因为你选择了一对像......
[happy.image release];
happy.image = [[UIImage alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"blah" ofType:@"png"]];
Run Code Online (Sandbox Code Playgroud)
如果你不这样做它就行不通.
下一个问题!使用视频的想法并不好,但您可以使用日常动画图像吗?从而...
#define BI(X) [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@X ofType:@"tif"]]
happyDays = [[NSArray alloc] initWithObjects:
BI("hh00"), BI("hh01"), BI("hh02"), BI("hh03"), BI("hh04"), BI("hh05"), BI("hh06"), BI("hh07"), BI("hh08"), BI("hh09"),
BI("hh10"), BI("hh11"), BI("hh12"), BI("hh13"), BI("hh14"), BI("hh15"), BI("hh16"), BI("hh17"), BI("hh18"), BI("hh19"), etc etc etc
nil];
animArea.animationImages = happyDays;
animArea.animationDuration = 2.88;
// that is overall seconds. hence: frames divided by about 30 or 20.
[animArea startAnimating];
Run Code Online (Sandbox Code Playgroud)
对你的情况没有好处?
无论如何,总而言之,你的问题是100 fps.改为20 fps,你就没有问题.让我们知道精确的图像大小(kb/xy).
| 归档时间: |
|
| 查看次数: |
2718 次 |
| 最近记录: |