适用于cocos2d v3.0的iphone 3.5英寸和4英寸的场景尺寸

时间:2014-05-10 00:35:15

标签: ios cocos2d-iphone

我的场景大小有些问题。我总是得到相同尺寸的UIScreen,因此我无法确定屏幕大小,我总是得到" 320x480" 3.5英寸iphone& 4英寸iphone。如何开始获取屏幕尺寸而不是" 320x480"?提前致谢http://lvkr.ru/u49S4A.jpg

2 个答案:

答案 0 :(得分:0)

你试过吗

[[UIScreen mainScreen] bounds].size

检查尺寸的高度和宽度对于3.5英寸屏幕应返回320x480,对于4英寸屏幕应返回320x568。

答案 1 :(得分:0)

use this for checking whether the device is iPhone 4 or 3.5 inch,then get y position or height for controller or view


+(BOOL)isDeviceiPhone5
{
    BOOL iPhone5 = FALSE;

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568) {
        // code for 4-inch screen
        iPhone5 = TRUE;
    }
    else
    {
        iPhone5 = FALSE;
        // code for 3.5-inch screen
    }
    return iPhone5;

}


+(CGRect )getFrameFor_iPhone4_height:(CGRect)frame
{
    frame.size.height = frame.size.height - 87.0;
    return frame;
}
+(CGRect )getFrameFor_iPhone4_yPos:(CGRect)frame
{
    frame.origin.y = frame.origin.y - 87.0;
    return frame;
}