0
votes

I am new for Cocos2d-x, I found strange issue in my game we are testing in all simulator that working fine. also we are testing our game in iPhone 5 and iPad all thing working perfect but got an issue in only iPhone 4 device. there is game screen display small and there are show top and right side black area like following screenshot:

enter image description here

I check its all Default images size and resolution is correct as par apple guide line.

Can you please suggest me how to fix this issue. i can't figure it out is there any code related issue or something need to change in xcode.

Following is iPhone 5 screen shot:

enter image description here


Here is my appdelegate code:

bool AppDelegate::applicationDidFinishLaunching()
{
    wrapper->authenticateLocalPlayer();
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    // turn on display FPS

    pDirector->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    CCSize Size = CCDirector::sharedDirector()->getWinSize();

    IPADX = Size.width/1024;
    IPADY = Size.height/768;

    if (Size.width==1024 || Size.width==2048){
        CCEGLView::sharedOpenGLView()->setDesignResolutionSize(1024, 768, kResolutionExactFit);
        SCALEX = 1.0f;
        SCALEY = 1.0f;
    }
    else
    {

            if (Size.width<568)
            {
                SCALEX = 960.0f/1024;
                SCALEY = 640.0f/768;

            }
            else
            {
                SCALEX = 1136.0f/1024;
                SCALEY = 640.0f/768;

            }
    }

        // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
1
Can you share your setup code?Vijay Masiwal
Are you using any DesignResolutionSize for glView ? Look Appdelegate.iphonic
Yes i used setDesignResolutionSize i edit my question please check @VijayMasiwal and iphonicNitin Gohel
@NitinGohel You have not set any resolution for iPhone 4, it should be 640x960iphonic
Can you please edit my code and put your answer i will impliment and let you know @iphonicNitin Gohel

1 Answers

0
votes

Try this:

//set design resolution

 Size designSize = Size(960, 640);
    if (Size.width==1024 || Size.width==2048){
        designSize = Size(1024, 768);
        SCALEX = 1.0f;
        SCALEY = 1.0f;
    }
    else
    {

        if (Size.width<568)
        {
            SCALEX = 960.0f/1024;
            SCALEY = 640.0f/768;

        }
        else
        {
            SCALEX = 1136.0f/1024;
            SCALEY = 640.0f/768;
            designSize = Size(1136, 640);
        }
    }

    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionExactFit);

    CCEGLView::sharedOpenGLView()->setContentScaleFactor(MAX(768/designSize.height,1024/designSize.width) );