2048游戏开发-从开发,打包到上架

2048游戏开发-从开发,打包到上架

游戏本身只是为了说明流程,主要梳理开发后的打包和上架,减少包的大小和安全性。

源码: https://github.com/thelogicwhy/2048-Godot

游戏开发本身先略过,后面可能会补也可能不会了,因为这部分不重要。。。

web版文档: https://docs.godotengine.org/zh-cn/4.x/engine_details/development/compiling/compiling_for_web.html

https://github.com/godotengine/godot/tags

找到对应开发工具的版本比如我的4.6-stable

git clone https://github.com/godotengine/godot.git -b 4.6-stable

安装Emscripten和SCons按官方文档 ,SCons是个python包,用pip安装

把custom.py拷贝到根目录下,禁用哪些包可以参考( https://godot-build-options-generator.github.io/ 以及 https://popcar.bearblog.dev/how-to-minify-godots-build-size/)我的是:

disable_3d = "yes"
threads = "no"
optimize = "size"
disable_advanced_gui = "yes"

deprecated = "no"
module_camera_enabled = "no"
module_enet_enabled = "no"
module_mobile_vr_enabled = "no"

vulkan = "no"
minizip = "no"

module_csg_enabled = "no"
module_gltf_enabled = "no"
module_gridmap_enabled = "no"
module_meshoptimizer_enabled = "no"
module_vhacd_enabled = "no"

module_theora_enabled = "no"
module_webrtc_enabled = "no"
module_websocket_enabled = "no"
module_webxr_enabled = "no"
module_openxr_enabled = "no"
module_upnp_enabled = "no"
module_multiplayer_enabled = "no"

cd到emsdk目录 source ./emsdk_env.sh 如果提示python没有(我电脑装了多个python)临时给一个需要的版本 export PATH="/usr/local/opt/python@3.14/bin:$PATH"

每次要source一下emsdk, 看到emcc --version才能打包web。

然后执行 scons platform=web target=template_release 打包web版

我的mac intel版 scons platform=macos arch=x86_64 target=template_release generate_bundle=yes 必须加generate_bundle才能生成包

把生成的zip文件放进godot项目文件夹,导出的时候点开高级选项,自定义模板->发布 里选那个zip模板。