Cocos2d iphone 在Cocos2d v 3中禁用iPad视网膜

Cocos2d iphone 在Cocos2d v 3中禁用iPad视网膜,cocos2d-iphone,Cocos2d Iphone,在CoCoS2D2.0中,我使用了下面的代码来禁用iPad的视网膜 if(!IS_IPAD) //In AppController.m { [director_ enableRetinaDisplay:YES]; } 现在AppDelegate没有这些调用。如何仅在iPad上禁用retina?您可能希望了解这一点。我也这么做,因为我想从一组纹理运行所有设备。。。我的纹理在所有设备上都非常“有效”,看起来很好 此设置在所有设备(568x384)上

在CoCoS2D2.0中,我使用了下面的代码来禁用iPad的视网膜

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

现在AppDelegate没有这些调用。如何仅在iPad上禁用retina?

您可能希望了解这一点。我也这么做,因为我想从一组纹理运行所有设备。。。我的纹理在所有设备上都非常“有效”,看起来很好

此设置在所有设备(568x384)上创建一个恒定大小的屏幕视口。我所有的“全背景”纹理都是1136x768像素,能够显示所有设备。这大大简化了布局,但代价很小。世界(0,0)不是屏幕视口(0,0)。例如,在4英寸iPhone(568x320)上运行时,屏幕视口左下角为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:)


反问:你为什么要这么做?你最终会在Retina iPad上看到一个“看起来不像视网膜”的应用程序,这意味着如果苹果认为最终的图像质量不适合Retina iPad,他们可能会拒绝该应用程序。该应用程序是经批准的cocos2d 2.0游戏。我有机会把它移植到COCOS2D3。有没有像2.0那样的方法可以避免iPad高清?现在一天的游戏下载主要取决于应用程序的大小。这是我们避免使用iPad hd的主要原因。你可以更改CCFileUtils使用的文件扩展名和回退,我相信你只需要将iPad上的全局contentScaleFactor设置为1.0。检查enableRetinaDisplay在v2中的作用,我相信它只是阻止contentScaleFactor接受1.0以外的值。@LearnCos2D有一个最简单的方法-在SetupCos2D中,添加了选项CCSetupTabletScale2X:@(是)。现在iPad高清使用iPad图像没有任何问题:)非常感谢您的快速回答。我找到了一条线路。在SetupCoCoS2WithOptions中添加了CCSetupTabletScale2X:@(是)。现在iPad高清使用iPad图像没有任何问题:)是的。。。我需要一些相当复杂的“运行时”游戏菜单布局作为设备类型的函数,您的修复对我来说只差一步:)
-(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 :)
}