3 Star 2 Fork 2

极客柒 / CocosCreator3DTo4399

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CocosCreator3DTo4399

介绍

开源 将cocos creator 3d 发布到4399网页小游戏 工具用途:

  1. 更改项目目录下 所有.cconb后缀更改为.bin格式
  2. 新建cconb管线处理所有 .cconb依赖更改其url
  3. 重写bin downloader 通过url判定处理 cconb 还是 bin

仓库地址

gitee

运行成功截图

相关错误

核心

新增一条处理 .cconb的资源管线

  //新加一个额外处理cconb的资源管道
  function append_cconb_convert_pip() {
    const assetManager = cc.assetManager;
    //新建一个额外处理cconb的资源管道
    assetManager.transformPipeline.append(function (task) {
      const input = task.output = task.input;
      for (let item of input) {
        if (!item.url) continue;
        //更改资源依赖
        item.url.endsWith(".cconb") && ( item.url = cc.path.changeExtname(item.url, ".cconb.bin") );
      }
    });
    //重写bin资源加载处理
    assetManager.downloader.register("bin", (url, options, onComplete) => {
      url.endsWith(".cconb.bin") ? assetManager.downloader._downloaders[".cconb"]() : assetManager.downloader._downloaders[".bin"]();
    })
  }

更改所有.cconb文件后缀

# 转换cconb格式 to bin
def ConvertConb2bin(dir):
    for root, dirs, files in os.walk(dir):
        path = root.replace('\\', '/')
        for f in files:
            url = '%s/%s' % (path, f)
            info = os.path.splitext(f)
            name = info[0]
            ext = info[1]
            if ext == ".cconb":
                os.rename(f"{root}/{f}", f"{root}/{name}.cconb.bin")
                print(f"{root}/{name}.cconb.bin")

注入管线到项目中

# 注入脚本到项目中
def intoApplication(dir):
    content = IUtils.fromFile(f"{dir}/application.js")
    content = content.replace(
        "function topLevelImport(url) {", "%s\n\tfunction topLevelImport(url) {" % cconbPip, 1)
    content = content.replace("return loadAssetBundle(settings.hasResourcesBundle, settings.hasStartSceneBundle);",
                              "append_cconb_convert_pip();//创建cconb管道\n\treturn loadAssetBundle(settings.hasResourcesBundle, settings.hasStartSceneBundle);", 1)
    IUtils.writeInFile(f"{dir}/application.js",content)

打包成EXE

需要提前安装 pyinstaller

pip install pyinstaller

打包命令

打开终端 输入 pyinstaller -f main.py

生成的exe在dist目录下

调用exe报错

需要手动在exe目录下 创建src目录 并将你的 web-mobile项目放入 src目录下

使用方法

将 cc打包后的 web-mobile 放入 src目录下运行 运行完成后 即可

程序入口

main.py

python 版本

3.9.9

Cocos Creator 版本

3.2.0

MIT License Copyright (c) 2022 极客七 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

开源 将cocos creator 3d 发布到4399网页小游戏 工具用途: 1. 更改项目目录下 所有.cconb后缀更改为.bin格式 2. 新建cconb管线处理所有 .cconb依赖更改其url 3. 重写bin downloader 通过url判定处理 cconb 还是 bin 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/welcome2jcSpace/cocos-creator3-dto4399.git
git@gitee.com:welcome2jcSpace/cocos-creator3-dto4399.git
welcome2jcSpace
cocos-creator3-dto4399
CocosCreator3DTo4399
master

搜索帮助