Objective C有大图片的iPad动画 - 使用什么方法? [英] Objective C iPad Animation with large images - What method to use?

查看:201
本文介绍了Objective C有大图片的iPad动画 - 使用什么方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iPad上建立一个天气应用程序,但似乎我需要一些动画的帮助。说我动画一个雷达,所以雷达源文件有10个gif / jpeg图片在900x700像素大小。我已经尝试使用这里的教程UIImage动画技术:

I'm trying to build a weather application on the iPad but it seems that I need some help in animation. Say I'm animating a Radar, so the radar source files have 10 gif/jpeg pictures in 900x700 pixel size. I've tried the UIImage animation technique using the tutorial here:

http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/

,但似乎加载10张图片太大,iPad无法处理,而且由于内存警告而崩溃。我正在研究其他技术来动画,但我似乎找不到有效的方法。

but it seems that loading 10 images that big is too much for the iPad to handle and its crashing due to memory warnings. I'm researching other techniques to animate but I can't seem to find something that will do this efficiently.

我已经看过其他人像Core Animation使用精灵,和Cocos2D与sprites。有人可以指向正确的方向最好的方式来动画这些大图像吗? (请记住,这些图像是动态的,并且经常变化,因此精灵必须在服务器上重新创建,并从iPad获取动画)。感谢

I've looked at others like Core Animation using sprites, and Cocos2D with sprites. Can someone point in the right direction the best way to animate these big images? (keep in mind that these images are dynamic and changes often so the sprites will have to be recreated on a server and fetched from the iPad to do the animation). Thanks

推荐答案

OpenGL仅创建尺寸为2的纹理。在图像的情况下,这是1024x1024,每个图像的内存百万。仍然,这不应该是iPad的问题。

OpenGL only creates textures with dimensions at powers of 2. In the case of your images, that's 1024x1024, which is a meg of memory per image. Still, that shouldn't be a problem with the iPad.

首先,调查使用Xcode的分析工具,以确保图像不会被重复加载到内存中的每个循环的动画(可能通过未共享缓存纹理的新对象)。这可以从一开始就解决你的问题。

First, investigate using Xcode's profiling tools to ensure the images aren't being repeatedly loaded into memory at each loop of the animation (likely by way of new objects that aren't sharing cached textures). That could solve your problem from the start.

其次,我推荐使用Cocos2D,如果只是为了容易处理纹理和缓存。将图像转换为CCAnimation,将其弹出到CCRepeatForever中,使用CCSequence运行它。完成后,点击CCTextureCache以释放未使用的纹理。

Second, I recommend using Cocos2D if only for the easy handling of textures and caching. Toss the images into a CCAnimation, pop that into a CCRepeatForever, run it with a CCSequence. When you're done hit CCTextureCache to release unused textures.

第三,将动画帧速率降低到30或更小(如果仅针对此动画)。它可能是iPad,但你做一个天气应用程序。不是视频游戏。

Third, lower your animation framerate to 30 or less (if only for this animation). It may be the iPad, but you making a weather app. Not a video game.

最后,降级图片的大小。证明你想要的,但一个大雷达动画不会卖你的应用程序。只是因为网站可能已经在精彩地播放这个动画,请记住,桌面比任何智能手机都拥有更多的内存和电源。

Finally, downgrade the size of your image. Justify all you want, but a large radar animation will not sell your app. And just because a website might already be playing that animation beautifully, remember that a desktop has vastly more memory and power than any smart phone.

这篇关于Objective C有大图片的iPad动画 - 使用什么方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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