简体   繁体   中英

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++.

The output, in the "Publish" folder, is my executable game and several .dll files. As well as the game resources. In other words, my game is not contained in a single .exe , which was my expected output.

Is it possible to build one single .exe file for my cocos2d-x game? One that has everything it needs contained?

The cocos console command I used for the build was

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. 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. This would remove the need to have any supplementary dlls.

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. 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 ).

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.


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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