如何区分iphone4和iphone 3 [英] How to differentiate between iphone4 and iphone 3
问题描述
我正在尝试使用cocos2d引擎为iphone构建游戏。我想知道如何区分用户是使用iphone 4还是iphone 3,因为我想加载iphone4的高分辨率图形和iphone 3的低分辨率。我知道我是否使用@ 2x.png如果我正在使用iphone 4,则图像文件名UIImage的末尾会自动加载高分辨率图像,但对于游戏,我使用cocos2d引擎的CCSprite类来加载图形。
I am trying to build a game for the iphone using cocos2d engine. I wanted to know how can I tell a difference whether the user is using iphone 4 or iphone 3 as I wanted to load hi-resolution graphics for the iphone4 and low-resolution for iphone 3. I know if I use @2x.png at the end of the image file name UIImage loads the hi-resolution image by itself if I am using an iphone 4 but for the game I am using cocos2d engine's CCSprite class to load the graphics.
我非常感谢你的回复。
问候,
Ankur
Regards, Ankur
推荐答案
您可以查看屏幕比例。
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2){
//iPhone 4
}
这篇关于如何区分iphone4和iphone 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!