我在尝试为Android设备选择设计分辨率时遇到了麻烦。
我只想拥有大约4-5个资源(图像,背景,精灵等),但可以在任何Android设备上运行。我能做出合适的设计决议是什么?例如,320x480,720x1280,还有什么?
你能给我一些建议吗?
由于
答案 0 :(得分:4)
In your AppDelegate class:
此分辨率适用于横向模式
bool AppDelegate::applicationDidFinishLaunching()
{
/********************** CCEGLView::sharedOpenGLView()->setDesignResolutionSize() //set design resolution size and mode
********************* CCEGLView::sharedOpenGLView()->getFrameSize() //get screen resolution
*********************CCDirector::sharedDirector()->getWinSize() //get design resolution
********************* CCDirector::sharedDirector()->getVisibleSize() //get design resolution’s visable area size
********************* CCDirector::sharedDirector()->getVisibleOrigin() //get origin of the visable area of design resolution*/
// initialize director
CCDirector* director = CCDirector::sharedDirector();
CCEGLView* EGLView = CCEGLView::sharedOpenGLView();
director->setOpenGLView(EGLView);
CCSize screenSize = EGLView->getFrameSize();
CCSize designSize = CCSizeMake(1024,614);
EGLView->setDesignResolutionSize(designSize.width,designSize.height, kResolutionExactFit);
CCLog("Screen Size:%f %f",screenSize.width,screenSize.height);
if(screenSize.height >= 320 && screenSize.height <= 480)
{
CCSize resourceSize = CCSizeMake(800, 480);
director->setContentScaleFactor(resourceSize.height/screenSize.height);
CCLog("Resolution Scale OF Default =%f",resourceSize.height/screenSize.height);
}
else if(screenSize.height >= 540 && screenSize.height < 720 )
{
CCSize resourceSize = CCSizeMake(960, 540);
director->setContentScaleFactor(resourceSize.height/screenSize.height);
CCLog("Resolution Scale OF Karboon=%f",resourceSize.height/screenSize.height);
}
else if (screenSize.height >= 720 && screenSize.height < 800)
{
CCSize resourceSize = CCSizeMake(1280, 720);
director->setContentScaleFactor(resourceSize.height/screenSize.height);
CCLog("Resolution Scale OF NOTE=%f",resourceSize.height/screenSize.height);
}
else if(screenSize.height > 800)
{
CCSize resourceSize = CCSizeMake(1920, 1080);
director->setContentScaleFactor(resourceSize.height/screenSize.height);
CCLog("Resolution Scale OF Nexus=%f",resourceSize.height/screenSize.height);
}
else
{
director->setContentScaleFactor(1);
CCLog("Resolution Scale OF S Advance=%f");
}