0

你好!我正在使用 Cocos2d 运行最基本的 Hello World 应用程序,它实际上没有从 Xcode 中最基本的 cocos2d 模板进行修改。

当我启动模拟器时,iPhone 5 的启动图像会自动加载 - 但是几秒钟后,启动图像会切换到 iPhone 4 的 default@2x,因此在启动图像的两侧都有两个未使用空间的小背带。

为什么会这样?以及如何使启动图像在几秒钟后不会自动切换到 iPhone 4 的较小版本?

谢谢

4

1 回答 1

0

在 IntroLayer.mm 添加以下代码:

    CCSprite *background;
    if( IS_IPAD)
    {
         if(IS_RETINA)
            background = [CCSprite spriteWithFile:@"Default-Portrait@2x~ipad.png"];
         else 
            background = [CCSprite spriteWithFile:@"Default-Portrait~ipad.png"];
    }
    else
    {
        if(IS_IPHONE5)
            background = [CCSprite spriteWithFile:@"Default-568h@2x.png"];
        else
        {
            if(IS_RETINA)
                background = [CCSprite spriteWithFile:@"Default@2x.png"];
            else
                background = [CCSprite spriteWithFile:@"Default.png"];
        }
}

使用宏:

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
#define IS_RETINA ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))
于 2013-08-21T02:18:21.630 回答