为什么cocos2d FPS是视网膜的一半?

时间:2012-06-10 17:15:33

标签: iphone ios cocos2d-iphone retina-display

情况:
iOS上的cocos2d。在模拟器中,我的FPS在标准分辨率设备模式下显示60,在视网膜设备模式下显示30(正好一半)。谷歌搜索没有立即产生结果......任何原因?

代码:

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
    // Init the window
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Init the View Controller
    viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
    viewController.wantsFullScreenLayout = YES;


    // Try to use CADisplayLink director
    // if it fails (SDK < 3.1) use the default director
    if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
        [CCDirector setDirectorType:kCCDirectorTypeDefault];

    // Create glview
    EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
                                   pixelFormat:kEAGLColorFormatRGBA8
                                   depthFormat:0
                        ];

     // make the OpenGLView a child of the view controller
     [viewController setView:glView];

     // make the View Controller a child of the main window
     [window addSubview: viewController.view];
     [window makeKeyAndVisible];

    // Create director
    director = [CCDirector sharedDirector];

    // attach the openglView to the director
    [director setOpenGLView:glView];

#if GAME_AUTOROTATION == kGameAutorotationUIViewController
    [director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#endif

    [director setAnimationInterval:1.0/60];
    [director setDisplayFPS:YES];
    [director setDeviceOrientation:kCCDeviceOrientationPortrait];

    // Set premultiplied alpha
    [CCTexture2D PVRImagesHavePremultipliedAlpha:YES];

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
    // You can change anytime.
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

    // Enable High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
    [director enableRetinaDisplay:YES]

    [self removeStartupFlicker];

    [SceneManager goLoadingScreen];
}

更新
也许这仅仅是一个模拟器问题?见http://www.cocos2d-iphone.org/forum/topic/20367

为什么不在设备上进行测试?
我不能只在我的视网膜设备上进行测试,因为我无知地将我的iPhone4升级到iOS的最新版本,而我还没准备好为Lion更新支付30美元......

1 个答案:

答案 0 :(得分:10)

原因可能是iPhone模拟器没有明确的GPU硬件加速。在设备上测试,一切都应该没问题。

我的游戏在iPad视网膜模拟器上是8fps,但在真实设备中是60 FPS。用真实设备测试游戏性能,不用担心模拟器。