Cocos2d-x在windows下实现全屏(cocos2d-x+win32+fullScreen)
来源:互联网 发布:真三国无双7捏脸数据 编辑:程序博客网 时间:2024/06/11 17:13
本人使用的cocos2dx版本为cocos2d-x_v2.1.5b,之前查到一些解决全屏的办法,但是这些方法对新版本已经不再适用,经过辛苦查询,总算是皇天不负有心人,找到了新版本的解决办法。参考原文:http://www.cocos2d-x.org/forums/6/topics/24432
方法如下:(亲测可行)
1、在目录cocos2dx\platform\win32下找到CCEGLView.h和CCEGLView.cpp,用记事本打开,在CCEGLView.h中添加如下代码
bool enterFullscreen(int fullscreenWidth=0, int fullscreenHeight=0);bool exitFullscreen(int windowX, int windowY, int windowedWidth, int windowedHeight, int windowedPaddingX, int windowedPaddingY);int getFullscreenWidth();int getFullscreenHeight();
2、在CCEGLView.cpp中添加如下代码
int CCEGLView::getFullscreenWidth(){ return GetDeviceCaps(m_hDC, HORZRES);}int CCEGLView::getFullscreenHeight(){ return GetDeviceCaps(m_hDC, VERTRES);}bool CCEGLView::enterFullscreen(int fullscreenWidth, int fullscreenHeight){ DEVMODE fullscreenSettings; bool isChangeSuccessful; if(fullscreenWidth == 0 || fullscreenHeight == 0) { fullscreenWidth = GetDeviceCaps(m_hDC, HORZRES); fullscreenHeight = GetDeviceCaps(m_hDC, VERTRES); } int colourBits = GetDeviceCaps(m_hDC, BITSPIXEL); int refreshRate = GetDeviceCaps(m_hDC, VREFRESH); EnumDisplaySettings(NULL, 0, &fullscreenSettings); fullscreenSettings.dmPelsWidth = fullscreenWidth; fullscreenSettings.dmPelsHeight = fullscreenHeight; fullscreenSettings.dmBitsPerPel = colourBits; fullscreenSettings.dmDisplayFrequency = refreshRate; fullscreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; SetWindowLongPtr(m_hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE); SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, fullscreenWidth, fullscreenHeight, SWP_SHOWWINDOW); isChangeSuccessful = ChangeDisplaySettings(&fullscreenSettings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; ShowWindow(m_hWnd, SW_MAXIMIZE); resize(fullscreenWidth, fullscreenHeight); return isChangeSuccessful;}bool CCEGLView::exitFullscreen(int windowX, int windowY, int windowedWidth, int windowedHeight, int windowedPaddingX, int windowedPaddingY){ bool isChangeSuccessful; SetWindowLongPtr(m_hWnd, GWL_EXSTYLE, WS_EX_LEFT); SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); isChangeSuccessful = ChangeDisplaySettings(NULL, CDS_RESET) == DISP_CHANGE_SUCCESSFUL; SetWindowPos(m_hWnd, HWND_NOTOPMOST, windowX, windowY, windowedWidth + windowedPaddingX, windowedHeight + windowedPaddingY, SWP_SHOWWINDOW); ShowWindow(m_hWnd, SW_RESTORE); return isChangeSuccessful;}
3、如何使用
在main.cpp中添加
// Create the application instance AppDelegate app; CCEGLView* eglView = CCEGLView::sharedOpenGLView(); // Set the frame size to the full screen value eglView->setFrameSize(eglView->getFullscreenWidth(), eglView->getFullscreenHeight()); // Enter full screen mode with the resolution size specified at exact fit eglView->setDesignResolutionSize(1024, 768, kResolutionExactFit); eglView->enterFullscreen(0, 0); int ret = CCApplication::sharedApplication()->run();
这样就能够实现全屏了!
这个是我修改过的版本:http://pan.baidu.com/share/link?shareid=3843693490&uk=4061830256
- Cocos2d-x在windows下实现全屏(cocos2d-x+win32+fullScreen)
- Cocos2d-x在windows下实现全屏(cocos2d-x+win32+fullScreen)
- Cocos2d-x在windows下实现全屏(cocos2d-x+win32+fullScreen)
- Cocos2d-x在Win32下全屏
- [cocos2d-x]在windows下创建cocos2d-x程序[important]
- Win32 下的Cocos2d-x
- cocos2d-x 在windows上实现键盘输入
- 在windows上搭建Cocos2d-x win32开发环境
- [Cocos2D-X]在windows8下:VS2012+Cocos2D-X-2.1.4+cygwin创建win32项目
- Cocos2d-x在win32下创建支持lua项目
- [cocos2dx]在windows7下搭建Cocos2D-X win32开发环境
- cocos2d-x下实现摇杆
- cocos2d-x·技巧]关于cocos2d-x在Android下实现单点触摸小技巧
- 在Windows XP3下搭建cocos2d-x-android开发环境
- Cocos2d-x 2.0 在Windows平台下的使用
- Cocos2d-x在Windows下音量设置无效的问题
- 在Windows环境下编译cocos2d-x-3.0
- 在Windows环境下编译cocos2d-x-3.0
- IO:重定向标准输出流
- HDU 4753 Fishhead’s Little Game (博弈+记忆话搜索)
- Java 线程池的原理与实现
- 选择时间对话框,在点击对话框外面的时候对话框不会自动关闭
- Collection
- Cocos2d-x在windows下实现全屏(cocos2d-x+win32+fullScreen)
- Android中Message传递参数【安卓进化十六】
- 看看你的android设备里有多少传感器?
- oracle密码文件详解
- 数据持久化之preference
- Lua程序设计第二版(笔记) 第六章深入函数
- Oracle 用户 profile 属性 .
- 超喜欢的一个HTML5 + CSS3 特效网站
- 希尔伯特空间