【发布时间】:2015-05-15 05:58:15
【问题描述】:
我是 Cocos2d-x 的新手,我在我的游戏中发现了奇怪的问题,我们正在所有运行良好的模拟器中进行测试。我们也在 iPhone 5 和 iPad 上测试我们的游戏,一切正常,但只在 iPhone 4 设备上出现问题。游戏画面显示小,顶部和右侧显示黑色区域,如下图所示:
我检查了它的所有默认图像大小和分辨率是否与苹果指南一样正确。
您能否建议我如何解决此问题。我不知道是否有任何与代码相关的问题或需要在 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;
}
【问题讨论】:
-
你能分享你的设置代码吗?
-
您是否使用任何
DesignResolutionSize用于 glView ?看看 Appdelegate。 -
是的,我使用了 setDesignResolutionSize 我编辑了我的问题,请检查@VijayMasiwal 和 iphonic
-
@NitinGohel 你没有为iPhone 4设置任何分辨率,应该是
640x960 -
你能否编辑我的代码并给出你的答案,我会暗示并让你知道@iphonic
标签: c++ ios iphone xcode cocos2d-x