mirror of https://github.com/axmolengine/axmol.git
issue #1486: Calculate content scale factor by screen height.
This commit is contained in:
parent
6178594068
commit
36600d95b1
|
@ -23,17 +23,17 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
if (screenSize.height > 768)
|
if (screenSize.height > 768)
|
||||||
{
|
{
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
|
||||||
pDirector->setContentScaleFactor(2048.0f/kDesignResolutionSize_width);
|
pDirector->setContentScaleFactor(1536.0f/kDesignResolutionSize_height);
|
||||||
}
|
}
|
||||||
else if (screenSize.height > 320)
|
else if (screenSize.height > 320)
|
||||||
{
|
{
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
|
||||||
pDirector->setContentScaleFactor(1024.0f/kDesignResolutionSize_width);
|
pDirector->setContentScaleFactor(768.0f/kDesignResolutionSize_height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
|
||||||
pDirector->setContentScaleFactor(480.0f/kDesignResolutionSize_width);
|
pDirector->setContentScaleFactor(320.0f/kDesignResolutionSize_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(kDesignResolutionSize_width, kDesignResolutionSize_height, kResolutionNoBorder);
|
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(kDesignResolutionSize_width, kDesignResolutionSize_height, kResolutionNoBorder);
|
||||||
|
|
|
@ -22,32 +22,26 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
TargetPlatform target = getTargetPlatform();
|
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
|
||||||
|
CCSize designSize = CCSizeMake(480, 320);
|
||||||
if (target == kTargetIpad)
|
|
||||||
{
|
|
||||||
// ipad
|
|
||||||
|
|
||||||
if (pDirector->enableRetinaDisplay(true))
|
if (screenSize.height > 768)
|
||||||
{
|
|
||||||
// ipad hd
|
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (target == kTargetIphone)
|
|
||||||
{
|
{
|
||||||
// iphone
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
|
||||||
|
pDirector->setContentScaleFactor(1536.0f/designSize.height);
|
||||||
if (pDirector->enableRetinaDisplay(true))
|
|
||||||
{
|
|
||||||
// iphone hd
|
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (screenSize.height > 640)
|
||||||
|
{
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
|
||||||
|
pDirector->setContentScaleFactor(768.0f/designSize.height);
|
||||||
|
}
|
||||||
|
else if (screenSize.height > 320)
|
||||||
|
{
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
|
||||||
|
pDirector->setContentScaleFactor(640.0f/designSize.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayStats(true);
|
pDirector->setDisplayStats(true);
|
||||||
|
|
Loading…
Reference in New Issue