在Cocos2d v 3中禁用iPad Retina

时间:2014-09-25 15:25:15

标签: cocos2d-iphone

在Cocos2d 2.0中,我使用下面的代码来禁用iPad的视网膜。

     if(!IS_IPAD)   //In AppController.m
     {
        [director_ enableRetinaDisplay:YES];
     }

现在AppDelegate没有这些电话。如何仅为iPad禁用视网膜?

1 个答案:

答案 0 :(得分:1)

您可能想要探索此问题。我这样做是因为我想从一组纹理中运行所有设备...而且我的纹理在所有设备上都非常“强大”,看起来很好。

此设置会在所有设备上创建一个大小恒定的ScreenViewPort,568x384。我所有的“全背景”纹理都是1136x768像素,能够显示所有设备。这大大简化了布局,但需要付出很小的代价。 World(0,0)不是ScreenViewPort(0,0)。例如,在4英寸iPhone(568x320)上运行时,ScreenViewPort左下角为0,32,而iPad上为28.0 ......

我们的里程数可能因iPhone 6的新显示尺寸而有所不同,当我获得一些设备并且可以确定其“可使用性”时,我会越过那条河流。

在AppDelegate中

NSString *kCCFileUtilsSuffixDefault = @"default";
NSString *kCCFileUtilsSuffixiPad = @"ipad";
NSString *kCCFileUtilsSuffixiPadHD = @"ipadhd";  
NSString *kCCFileUtilsSuffixiPhone = @"iphone";
NSString *kCCFileUtilsSuffixiPhoneHD = @"iphonehd";
NSString *kCCFileUtilsSuffixiPhone5 = @"iphone5";
NSString *kCCFileUtilsSuffixiPhone5HD = @"iphone5hd";
//NSString *kCCFileUtilsSuffixMac = @"mac";
//NSString *kCCFileUtilsSuffixMacHD = @"machd";

NSDictionary *dic = [CCFileUtils sharedFileUtils].suffixesDict;
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixDefault];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPad];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPadHD];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhoneHD];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone5];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone5HD];

[self setupCocos2dWithOptions:@{
        // Show the FPS and draw call label.
        CCSetupShowDebugStats : @(YES),

        // More examples of options you might want to fiddle with:
        // (See CCAppDelegate.h for more information)
        // Use a 16 bit color buffer:
        // CCSetupPixelFormat: kEAGLColorFormatRGB565,

        // Use a simplified coordinate system that is shared across devices.
        CCSetupScreenMode : CCScreenModeFixed,

        // Run in landscape mode.
        CCSetupScreenOrientation : CCScreenOrientationLandscape,

        // Run at a reduced framerate.
        CCSetupAnimationInterval : @(1.0 / 30.0),

        // Run the fixed timestep extra fast.
        CCSetupFixedUpdateInterval : @(1.0 / 60.0),

        // Make iPad's act like they run at a 2x content scale. (iPad retina 4x)
       //       CCSetupTabletScale2X: @(YES),
}];

[CCTexture PVRImagesHavePremultipliedAlpha:YES];

和CCFileUtils,一个小mod :)

-(CGFloat) contentScaleForKey:(NSString*)k inDictionary:(NSDictionary *)dictionary{
    // XXX XXX Super Slow
    // ylb fix for single set of textures
    return 2.0f;
    // ylb fix : super fast now :)
}