我是Cocos2d-x的新手,我在我的游戏中发现了一个奇怪的问题,我们正在所有模拟器中测试工作正常。我们也正在iPhone 5和iPad上测试我们的游戏,所有东西都很完美,但只在iPhone 4设备上出现问题。游戏画面显示小,并且显示顶部和右侧黑色区域,如下面的屏幕截图:
我检查它的所有默认图像大小和分辨率是否正确作为par apple guide line。
您能否建议我如何解决此问题。我无法弄清楚是否有任何与代码相关的问题或需要在xcode中更改的内容。
以下是iPhone 5屏幕截图:
这是我的appdelegate代码:
bool AppDelegate::applicationDidFinishLaunching()
{
wrapper->authenticateLocalPlayer();
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
CCSize Size = CCDirector::sharedDirector()->getWinSize();
IPADX = Size.width/1024;
IPADY = Size.height/768;
if (Size.width==1024 || Size.width==2048){
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(1024, 768, kResolutionExactFit);
SCALEX = 1.0f;
SCALEY = 1.0f;
}
else
{
if (Size.width<568)
{
SCALEX = 960.0f/1024;
SCALEY = 640.0f/768;
}
else
{
SCALEX = 1136.0f/1024;
SCALEY = 640.0f/768;
}
}
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
答案 0 :(得分:0)
试试这个:
//设置设计分辨率
Size designSize = Size(960, 640);
if (Size.width==1024 || Size.width==2048){
designSize = Size(1024, 768);
SCALEX = 1.0f;
SCALEY = 1.0f;
}
else
{
if (Size.width<568)
{
SCALEX = 960.0f/1024;
SCALEY = 640.0f/768;
}
else
{
SCALEX = 1136.0f/1024;
SCALEY = 640.0f/768;
designSize = Size(1136, 640);
}
}
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionExactFit);
CCEGLView::sharedOpenGLView()->setContentScaleFactor(MAX(768/designSize.height,1024/designSize.width) );