Skip to content

Instantly share code, notes, and snippets.

@takashi1975
Last active March 15, 2016 23:37
Show Gist options
  • Save takashi1975/834dd9c4aa0d3df9f6a8 to your computer and use it in GitHub Desktop.
Save takashi1975/834dd9c4aa0d3df9f6a8 to your computer and use it in GitHub Desktop.
Cocos2d-x ver.3.7.1 画面解像度 (メモ書き)
//解像度設定
{
//横画面
//const auto designResolutionSize = Size( 480, 320);
//const auto smallResolutionSize = Size( 480, 320);
//const auto mediumResolutionSize = Size(1024, 768);
//const auto largeResolutionSize = Size(2048, 1536);
//縦画面
const auto designResolutionSize = Size( 320, 480);
const auto smallResolutionSize = Size( 320, 480);
const auto mediumResolutionSize = Size( 768, 1024);
const auto largeResolutionSize = Size(1536, 2048);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width,
designResolutionSize.height,
ResolutionPolicy::NO_BORDER);
//スケール
{
const auto frameSize = glview->getFrameSize();
auto targeResolution = Size::ZERO;
// //リソースを分ける場合
// if (false)
{
const auto frameMinLength = MIN(frameSize.width, frameSize.height);
const auto smallMinLength = MIN(smallResolutionSize.width, smallResolutionSize.height);
const auto mediumMinLength = MIN(mediumResolutionSize.width, mediumResolutionSize.height);
//const auto largeMinLength = MIN(largeResolutionSize.width, largeResolutionSize.height);
// if the frame's height is larger than the height of medium size.
if (frameMinLength > mediumMinLength)
{
targeResolution = largeResolutionSize;
}
// if the frame's height is larger than the height of small size.
else if (frameMinLength > smallMinLength)
{
targeResolution = mediumResolutionSize;
}
// if the frame's height is smaller than the height of medium size.
else
{
targeResolution = smallResolutionSize;
}
}
// //リソースを単一で扱う場合
// else
// {
// //端末ごとのサイズになるからダメですね...
// targeResolution = frameSize;
// }
const auto scale = MIN(targeResolution.height / designResolutionSize.height,
targeResolution.width / designResolutionSize.width);
director->setContentScaleFactor(scale);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment