【cocos2d-x 3.4】全屏显示窗口,隐藏标题栏

来源:互联网 发布:网络对我们的影响 编辑:程序博客网 时间:2024/05/22 04:35

方法一 :

首先,修改appDelegate::applicationDidFinishLaunching()

函数

    auto director = Director::getInstance();    auto glview = director->getOpenGLView();    if(!glview) {        glview = GLViewImpl::create("My Game");        director->setOpenGLView(glview);        glview->setDesignResolutionSize(1920, 1080, ResolutionPolicy::SHOW_ALL);    }

效果图:
这里写图片描述
默认创建函数是create(),改成如下:

    auto director = Director::getInstance();    auto glview = director->getOpenGLView();    if(!glview) {        glview = GLViewImpl::createWithFullScreen("My Game");        director->setOpenGLView(glview);        glview->setDesignResolutionSize(1920, 1080, ResolutionPolicy::SHOW_ALL);    }

这样编译后就是全屏了, 看看效果:
这里写图片描述

方法二 :

cocos2d\cocos\platform\desktop\CCGLViewImpl-desktop.cpp

修改即可,在工程里面可以从GLViewImpl进入 ,F12即可进入了
找到下面的方法:

bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor){    setViewName(viewName);    _frameZoomFactor = frameZoomFactor;    glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);//在此后加一段代码    glfwWindowHint(GLFW_RED_BITS,_glContextAttrs.redBits);  //............   } 

加上这句 glfwWindowHint(GLFW_DECORATED, GL_FALSE);
编译后 ,效果一样全屏。

1 0
原创粉丝点击