简体   繁体   English

在通用ios应用程序中管理资源

[英]Managing resources in a universal ios app

I am developing a cocos2d game. 我正在开发一个cocos2d游戏。 I need to make it universal. 我需要使其通用。 Problem is that I want to use minimun amount of images to keep the universal binary as small as possible. 问题是我想使用最少数量的图像来使通用二进制文件尽可能小。 Is there any possibility that I can use same images I am using for iphone, retina and iPad somehow? 我是否有可能以某种方式使用与iPhone,Retina和iPad相同的图像? If yes, how can I do that? 如果是,我该怎么做? What image size and quality should it be? 图像大小和质量应该是多少? Any suggestion? 有什么建议吗?

Thanks and Best regards 谢谢和最好的问候

As for suggestions: provide HD resolution images for Retina devices and iPad, provide SD resolution images for non-Retina devices. 至于建议:为Retina设备和iPad提供高清分辨率的图像,为非Retina设备提供SD分辨率的图像。 Don't think about an all-in-one solution - there isn't one that's acceptable. 不要考虑一个多合一的解决方案-没有一个可以接受的解决方案。

  1. Don't upscale SD images to HD resolution on Retina devices or iPad. 不要在Retina设备或iPad上将SD图像升级到高清分辨率。 It won't look any better. 看起来不会更好。

  2. Don't downscale HD images for non-Retina devices. 不要为非Retina设备缩小HD图像的尺寸。 Your textures will still use 4x the memory on devices that have half or even a quarter of the memory available. 您的纹理仍将使用具有一半甚至四分之一可用内存的设备上4倍的内存。 In addition, downscaling images is bad for performance because it has to be done by the CPU on older devices. 另外,缩小图像尺寸对性能不利,因为它必须由旧设备上的CPU完成。 While you could downscale the image and save the downscaled texture, it adds a lot more complexity to your code and will increase the loading time. 尽管您可以缩小图像的尺寸并保存缩小的纹理,但它会增加代码的复杂性,并会增加加载时间。

There's not a single right answer to this question. 这个问题没有一个正确的答案。 One way to do it is to create images that are larger than you need and then scale them down. 一种方法是创建大于您需要的图像,然后按比例缩小。 If the images don't have a lot of fine detail, that should work pretty well. 如果图像没有很多细节,那应该可以很好地工作。 As an example, this is the reason that you submit a 512x512 pixel image of your app icon along with your app to the App Store. 例如,这就是您将应用程序图标的512x512像素图像与应用程序一起提交到App Store的原因。 Apple never displays the image at that size, but uses it to create a variety of smaller sizes for display in the App Store. Apple从未以该尺寸显示图像,而是使用它来创建各种较小的尺寸以在App Store中显示。

Another approach is to use vector images, which you can draw perfectly at any size that you need. 另一种方法是使用矢量图像,您可以根据需要任意绘制完美的图像。 Unfortunately, the only vector format that I can think of that's supported in iOS is PDF. 不幸的是,我能想到的iOS唯一支持的矢量格式是PDF。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM