什么是逐帧动画技术在iPhone SDK的最简单的框架? [英] What's the easiest frame by frame animation technique in the iPhone sdk?

查看:153
本文介绍了什么是逐帧动画技术在iPhone SDK的最简单的框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为iPhone开发平台约3周,我想成立由帧动画帧与16 1000×1000 PNG图像(透明),并计划与后来约100动画,所以首先我试着使用imageNamed动画所有这样的图像

i've been developing for the iphone platform for about 3 weeks now, and I'm trying to set up a frame by frame animation with 16 1000x1000 png images (with transparency) and plan on animating with around 100 later, so first I tried using imageNamed to animate all the images like this



     - (IBAction为)startClick1:(ID)发送者
{
    cloud.animationImages = [NSArray的arrayWithObjects:
    [UIImage的imageNamed:@g0000.png],
    [UIImage的imageNamed:@g0001.png],
    [UIImage的imageNamed:@g0002.png],
    [UIImage的imageNamed:@g0003.png],
    [UIImage的imageNamed:@g0004.png],

现在这个工作正常在模拟器上,但是当它来到了设备的设备刚刚重新启动时,第一次尝试动画,大概从imageNamed已知的内存问题,所以做了一些研究之后,我发现imageWithContentsOfFile应该不缓存图像,希望不会造成iphone重启时要求要播放的动画,所以我改变了我的code到这样的事情:

Now this worked fine in the simulator, but when it came to the device the device just reboots when it first attempts the animation, probably from the known memory issues with imageNamed, so after doing some research I found out that imageWithContentsOfFile is supposed to not cache the images and hopefully won't cause the iphone to reboot when the animation is requested to play so I changed my code to something like this:

- (IBAction为)startClick:(ID)发送者
{
    gordon.animationImages = [NSArray的arrayWithObjects:
    [UIImage的imageWithContentsOfFile:[一个NSBundle mainBundle] pathForResource:@g0001.pngofType:无],
    [UIImage的imageWithContentsOfFile:[一个NSBundle mainBundle] pathForResource:@g0002.pngofType:无],
    [UIImage的imageWithContentsOfFile:[一个NSBundle mainBundle] pathForResource:@ge0003.pngofType:无],
    [UIImage的imageWithContentsOfFile:[一个NSBundle mainBundle] pathForResource:@g0004.pngofType:无],
    [UIImage的imageWithContentsOfFile:[一个NSBundle mainBundle] pathForResource:@g0005.pngofType:无],
    [UIImage的imageWithContentsOfFile:[一个NSBundle mainBundle] pathForResource:@g0006.pngofType:无]]

现在这个运行在模拟器上车,并以同样的方式在imageNamed方法做了设备上不起作用。那么,什么是动画图像序列,将在设备上运行良好的最好和最简单的方法是什么?哦,并回答时,请记住,我是新来这个平台。

Now this runs buggy in the simulator and doesn't work on the device in the same way the imageNamed method did. So, what's the best and easiest way to animate a sequence of images that will run fine on the device? Oh and when answering remember that I'm new to this platform.

推荐答案

一个主要imageNamed之间的区别就是imageNamed返回已经$ P $图像对DECOM pressed

One major difference between imageNamed: and imageWithContentsOfFile: is that imageNamed returns an image that has been pre-decompressed.

您可以在不需要图像创建自己的优化的版本通过查看<一个缓存href=\"http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud/938332#938332\">this回答。

You can create your own "optimized" version without requiring the images to be cached by looking at this answer.

现在,我注意到你1000×1000加载图像,但屏幕尺寸只有小320x480。你缩减图像,裁剪,还是什么?如果你是按比例缩小,考虑pre-缩减图像。此外,为您的动画意思是30fps的呢,还是更像幻灯片动画?

Now, I notice you're loading 1000x1000 images, but the screen size is only 320x480. Are you downscaling the image, cropping, or what? If you are downscaling, consider pre-downscaling the image. Also, is your animation meant to be 30fps, or is it more like a slideshow animation?

最后,我会建议装载了动画的帧上的需求。正如你所看到的,1000×1000的图像占用过多的内存,以保持加载优化。如果你每次只保留一个在内存中,你会不会崩溃,但你必须非常小心你的code任何停顿。如果你正在做一个幻灯片肯伯恩斯式的效果,可以pre-优化(DECOM preSS)一个图像为幻灯片的时间画画。

Finally, I would recommend loading up the frames of animation on demand. As you can see, 1000x1000 images take up too much memory to keep loaded optimized. If you only keep one in memory at a time, you won't crash, but you then have to be very careful about any pauses in your code. If you're doing a slideshow "ken burns" type effect, you can pre-optimize (decompress) one image for drawing for the duration of the slide.

如果你打算支持30fps,则需要削减图像尺寸得到加快。

If you're going for 30fps, you need to cut down the image size to get the speed up.

这篇关于什么是逐帧动画技术在iPhone SDK的最简单的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆