Jiří Zahálka
Jiří Zahálka

Reputation: 8258

Simulator with iPad retina display

I have a problem with the simulator, I try to make the app with space manager and in my delegate.m I have this source.. I try to set code for each device specifficaly and there where is written //HERE IS THE PROBLEM, I try to set code for ipad with retina display and when I start my simulator everything works perfectly on , but ipad with retina display doesn t load, it loads only if I set there [director enableRetinaDisplay:NO]; and then it runs without retina. So does anyone know, how to set it to allow retina display to work it in another way? Thanks.

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone )
{
    CGSize result = [[UIScreen mainScreen] bounds].size;


    if(result.height == 480 && [director enableRetinaDisplay:YES] == YES)
    {
        NSLog(@"iphone 4");
         [[CCDirector sharedDirector] replaceScene:[GameLayer node]];
    }


    if(result.height == 480 && [director enableRetinaDisplay:YES] == NO)
    {
        NSLog(@"iphone 3");
        [[CCDirector sharedDirector] replaceScene:[GameLayer node]];
    }



    if(result.height == 568)
    {
        NSLog(@"iphone 5");
        [[CCDirector sharedDirector] replaceScene:[Menu node]];
    }

}


if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;


    if(result.height == 1024 && [director enableRetinaDisplay:YES] == NO)
    {
        NSLog(@"iPad");
        [[CCDirector sharedDirector] replaceScene:[GameLayer node]];
    }

    if([director enableRetinaDisplay:YES] == YES)
    {
        NSLog(@"iPad retina");

        //HERE IS THE PROBLEM
        //HERE IS THE PROBLEM
        //[director enableRetinaDisplay:NO];

        [[CCDirector sharedDirector] replaceScene:[GameLayer node]];
    }
}

Upvotes: 1

Views: 450

Answers (1)

T. Benjamin Larsen
T. Benjamin Larsen

Reputation: 6383

This is a known bug in earlier Cocos2D builds, but can fairly easily be remedied by a small change to the CCDirectorIOS class. You need to replace line 212/213 with the following lines:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
[[UIScreen mainScreen] scale] > 1.0 )
{gluPerspective(60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2 );
} else {
gluPerspective(60, (GLfloat)size.width/size.height, 0.5f, 1500);
}

NB: This is NOT my fix, I just came across it googling after experiencing the same problem. The full explanation can be found here: http://swainya.blogspot.no/2012/03/black-screen-on-simulator-for-ipad.html credit goes to Spencer Ho...

Upvotes: 1

Related Questions