前言
本示例使用Quick-Cocos2dx-Commucity开发,用VS2019打包发布游戏。演示简易的打包Win平台下的游戏.exe。
操作步骤
1. 首先这是开发的文档:
- frameworks: 存放Cocos2d-x引擎核心代码及各个平台运行时资源
- res:存放项目资源的文件夹
- src:项目源码所存放文件夹,即游戏中的所有的 .lua 文件都放在这里
2. 进入frameworks:
- cocos2d-x:cocos2d-x框架
- runtime-src:存放预编译的运行时库
3. 进入runtime-src:
- 这里关注win32平台即可。
- win32文件夹:
需要注意的是:
- 这分别是vs编译的debug,release版本,编译成功会生成。
编译需要这个文件,我是直接用的QT中的这个文件,编译无误。【暂时不去管这个文件的作用】
自取 afxres.h
:
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _AFXRES_H
#define _AFXRES_H
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _INC_WINDOWS
#include <windows.h>
#endif
/* IDC_STATIC is documented in winuser.h, but not defined. */
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#ifdef __cplusplus
}
#endif
#endif
4. 进入VS2019,进行编译:
- 打开.sln文件
- 选择版本【Debug、Release】,本地Windows调试器,直接进行编译。
- 编译成功之后,会生成
Release.win32
文件夹,文件夹中即有对应的.exe
可程序程序。 - 将资源文件放到exe同级目录下,按理就能正常跑通。
- 我exe能正常执行,说明dll动态链接库都没问题。但是运行是黑屏,不知道出了什么问题,一直没调成功。有懂的大佬求评论区教教!!!
5. 项目屏幕大小的调整
- 工程项目:
找到 AppDelegate.cpp
,定位在第
98
98
98 行:glview = cocos2d::GLViewImpl::create(title.c_str());
上下。
进入 create
函数,跳转到 CCGLViewImpl-desktop.cpp
文件:
直接在 initWithRect
中修改,此处是 (480,800)。