Multiresolution using Exact Fit

Hello there!

I’ve been trying to solve this for hours now, please help. I’m trying to make my app support multiresolution on IOS (ipad, ipad retina, iphone 3.5, 4.0 inch), it works well for iPhone 3.5 and 4.0 retina, on the ipad, the backgroundimage I added to the scene is out of the visible area on all the 4 sides (so the image is bigger than it should be), in the ipad folder there are 2048x1536 images. So referring to this page [[http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support]], it should work well. I’m using exactfit policy, because I have resources for only iphone 3.5, so I just want it to be streched on 4.0.

On my scene I just set my images position to ccp(480, 320), but I don’t think this should matter.

@
Resolution::decideDevice();

std::vectorstd::string resDirOrders;
pEGLView->setDesignResolutionSize(960, 640, kResolutionExactFit);

//if it’s an ipad (Resolution::IPAD = 0, Resolution::IPAD_RET = 1)
if(Resolution::getDevice() <= Resolution::IPAD_RET){
resDirOrders.push_back(“ipad”);
CCFileUtils::sharedFileUtils()>setSearchPaths;
pDirector
>setContentScaleFactor(1536/640);

}
//if it’s an iphone (Resolution::IPHONE = 2, Resolution::IPHONE_RET = 3)
else{
resDirOrders.push_back(“iphone”);
CCFileUtils::sharedFileUtils()>setSearchPaths;
pDirector
>setContentScaleFactor(640/640);

}

@

So, anyone any help?

This is easy.

I use the code below, to stretch all my games images in all devices, Iphone 3GS, Iphone 4, Iphone 5, Ipad, Ipad 2, incuding all android devices.

use it in appdelegate.cpp

bool AppDelegate::applicationDidFinishLaunching() {

    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionExactFit);
    pDirector->setDisplayStats(false);
    pDirector->setAnimationInterval(1.0 / 60);
    CCScene *pScene = SplashScene::scene();
    pDirector->runWithScene(pScene);

    return true;
}

What should I see here? Why should it work? It’s just makes my graphics huge.

My configuration is based in 480x320px.
My background have 480x320px and fill the entire screen, your configuration probably will be 960x640.
Anything that is huge than 480x320px will not appear.

Just change the following line:

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionExactFit);

to

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionExactFit);

or

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(MAXIMUM_WIDTH_IN_PIXELS, MAXIMUM_HEIGHT_IN_PIXELS, kResolutionExactFit);

My graphic assets is independent from device resolution, for the code above work this is necessary.

dear fabio cunha, when i set follow you, i also two border black in game .

i added these line to appdalegate same you :"

CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionExactFit);
    pDirector->setDisplayStats(false);
    pDirector->setAnimationInterval(1.0 / 60);
    CCScene *pScene = SplashScene::scene();
    pDirector->runWithScene(pScene);

    return true;

What exactly code do you use “Vu Minh Tuan”?

The two black border problem only happens in iPhone5 if you don’t set the image Default-568h@2x.png.

What device do you try to use the code?

yup, i test on device iphone 5. i don’t know “Default-568h@2x.png”. can u send me, and how to use it thank you very much

i think strech all image look not beautiful,

Example, circle become eclipse shape

You are right, a circle become an eclipse shape, but this will save time when you create a game, I not use circle and square objects in my games.

You can use any image with resolution 640x1136 or 1136x640

Xcode have a place for you to use a retina 4.0 image, look for it.

If this image is not set they will not put the image size in the resolution of the iphone5.

Or Just download this file and use in your project
https://github.com/ingo/titanium_mobile/diff_blob/5c38b2cd5ad00e01cd58600d8e5ba3157d8cefa9/iphone/templates/app/default/Resources/iphone/Default-568h@2x.png?raw=true

so do you have other resolution ?

The image default568@2x.png must be use one of this resolutions (640x1136px or 1136x640px), this will not affect the resolution that you set for your game