cocos3.2编译android平台,屏幕无法适配

cocos3.2编译android平台,屏幕无法适配

bool AppDelegate::applicationDidFinishLaunching()
{
auto director = Director::getInstance();
auto glview = director->getOpenGLView();

//auto size = Director::sharedDirector()->getWinSize();
if (!glview)
{
    glview = GLView::create("My Game");
    director->setOpenGLView(glview);
    
    glview->setFrameSize(320, 480);
    
    //glview->setDesignResolutionSize(640,960, ResolutionPolicy::SHOW_ALL);
    glview->setDesignResolutionSize(640,960, ResolutionPolicy::EXACT_FIT);
    
}
director->setAnimationInterval(1.0 / 60);
auto scene = LoginSceneLayer::scene();
director->runWithScene(scene);
return true;

}

这是我的入口函数,但是android真机根本没有和pc上面一样显示,已经改成竖屏了

你在配置文件中也要改啊,那个proj.android中的androidManifest.xml也要改,android:screenOrientation=“portrait”,这个就是坚屏的

glview->setDesignResolutionSize(640,960, ResolutionPolicy::EXACT_FIT);放到if外面

— Begin quote from ____

引用第2楼luckyyangl于2014-11-03 17:27发表的 :
glview->setDesignResolutionSize(640,960, ResolutionPolicy::EXACT_FIT);放到if外面 http://www.cocoachina.com/bbs/job.php?action=topost&tid=237391&pid=1089401

— End quote

赞同,当时也是折腾了这个好久,放到外边突然好了,想起来当时看的教程要放里边的 就感觉要坑死了……

还有就是 glview->setFrameSize(320, 480); 这句一定要放在if()里边,不然到手机上就会不全屏了

简直了,感谢!