简体   繁体   English

是否可以为我的 cocos2d-x 游戏构建一个单一的 .exe 文件?

[英]Is it possible to build one single .exe file for my cocos2d-x game?

I managed to build a Windows executable for my cocos2d-x game using the cocos console and Visual Studio 2015 Express C++.我设法使用 cocos 控制台和 Visual Studio 2015 Express C++ 为我的 cocos2d-x 游戏构建了一个 Windows 可执行文件。

The output, in the "Publish" folder, is my executable game and several .dll files. “发布”文件夹中的输出是我的可执行游戏和几个.dll文件。 As well as the game resources.还有游戏资源。 In other words, my game is not contained in a single .exe , which was my expected output.换句话说,我的游戏不包含在单个.exe ,这是我预期的输出。

Is it possible to build one single .exe file for my cocos2d-x game?是否可以为我的 cocos2d-x 游戏构建一个单一的 .exe 文件 One that has everything it needs contained?一个拥有它需要的一切?

The cocos console command I used for the build was我用于构建的 cocos 控制台命令是

cocos deploy -p WIN32 -m RELEASE

Probably not.可能不是。 But you could try.不过你可以试试。

You would need to change the project quite a lot however:但是,您需要对项目进行很多更改:

You would need to add the explicit cocos framework project to your workspace, and change that to generate static libraries.您需要将显式 cocos 框架项目添加到您的工作区,并更改它以生成静态库。 Repeat that for all other 3rd party libraries that are being included as dlls - including changing all the projects to use the static rather than dynamic c runtime.对作为 dll 包含的所有其他 3rd 方库重复此操作 - 包括将所有项目更改为使用静态而不是动态 c 运行时。 This would remove the need to have any supplementary dlls.这将消除对任何补充 dll 的需要。

What would remain would be the assets.剩下的就是资产。 Here you would need to create a windows RC file and add all your assets as RT_BINARY resources to that.在这里,您需要创建一个 Windows RC 文件并将您的所有资产作为 RT_BINARY 资源添加到该文件中。 To actually load resources from your EXE's resources chunk you would need to provide a custom version of cocos2d::FileUtils, and override all the getFileDataFrom(... methods to look first in the exe's resources using the relevant win32 apis ( FindResource , LoadResource , LockResource ).要从 EXE 的资源块中实际加载资源,您需要提供 cocos2d::FileUtils 的自定义版本,并覆盖所有 getFileDataFrom(... 方法以使用相关的 win32 apis ( FindResourceLoadResourceLockResource )。

Very likely however there are parts of coco's that require a file path and will explicitly use file io to read from the file, in which case you would override FileUtils::fillPathForFilename to write out the resource as a file to a temp folder, and return that path to cocos.但是很可能有部分 coco 需要文件路径,并且将显式使用文件 io 从文件中读取,在这种情况下,您将覆盖FileUtils::fillPathForFilename以将资源作为文件写出到临时文件夹,然后返回通往可可的那条路。


Here is a useful blog post showing how to embed resources in a win32 binary: * https://blog.kowalczyk.info/article/zy/Embedding-binary-resources-on-Windows.html这是一篇有用的博客文章,展示了如何在 win32 二进制文件中嵌入资源: * https://blog.kowalczyk.info/article/zy/Embedding-binary-resources-on-Windows.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM