Hi to everyone,
This is my first topic and I really need help with multiple resolutions in Android.
I’ve already read the tutorials in the Learn page about multi resolutions, and all the theory about setDesignResolutionSize(float, float, ResolutionPolicy) and setContentScaleFactor(DesignResolution.widht / ScreenResolution.with). I also searched this topic on forum but didn’t get any success.
Please post code for multiple screen resolution in android.
bool AppDelegate::applicationDidFinishLaunching() {
//initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
glview->setDesignResolutionSize(480,320,ResolutionPolicy::EXACT_FIT);
// this line is working fine on win32 but not working on android devices.
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = MainMenu::createScene();
// run
director->runWithScene(scene);
return true;
}
i am using the following code for displaying the background image -
Background image is not covering hole screen on 800x480 resolution device. but on 480x320 resolution device full image is not visible only center part of image is covering hole screen of device. My Background image resolution is 800x480.
Or, to expand the image until either the left/right sides first touch the edge of the screen or the top/bottom sides do (which may give you black bars):
setContentScaleFactor() is supposed to be used for that. Just choose a design size you want to work with and set the content scale factor based on that.
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create(“My Game”);
director->setOpenGLView(glview);
}