Coder Social home page Coder Social logo

hotupdate-panel-description's Introduction

2.4.x bundle 大厅子游戏单独热更新

【请不要下载项目后立即用 Cocos Creator 打开项目 !!】

【请按照运行指引运行项目 !!】

【此项目基于 Cocos Creator 2.4.9,理论上支持所有 2.4.x 版本】

亮点介绍

  1. 大厅、子游戏分离,子游戏分包下载

  2. 新增游戏无需更新包体,新增配置即可

  3. 简洁易懂,界面化操作

关键目录结构、文件简介

|-- assets
    |-- resources
        |-- manifest    // 项目manifest文件存放目录
    |-- Script
        |-- hotUpdate
            |-- HotUpdateEvent.ts   // 热更新事件
            |-- MainHotUpdate.ts    // 主包热更新脚本
            |-- SubGameHotUpdate.ts // 子游戏热更新脚本
            |-- VersionTool.ts      // 版本工具
        |-- subGame
            |-- SubGameCtrl.ts      // 子游戏控制器
            |-- SubGameInterface.ts // 子游戏接口相关
            |-- SubGameMgr.ts       // 子游戏管理器
        |-- BackHall.ts         // 回大厅统一脚本
        |-- GameConst.ts        // 游戏常理存放
        |-- HallSceneCtrl.ts    // 大厅场景控制脚本
        |-- Intro.ts            // 初始化脚本(同时也挂载在Intro场景)
|-- hot-update-packages // 热更包目录
    |-- manifest
    |-- server      // 本地服务器根目录,远程服务器目录结构可参考此目录
        |-- ...     // 生成热更后,会复制一份至该目录,所以此处热更包永远是最新的
        |-- http-server         //mac http-server 执行文件
        |-- http-server.bat     //windows http-server 执行文件
        |-- subGameConfig.json  // 子游戏配置
    |-- versions    // 存放历史各个版本热更包
|-- packages
    |-- hot-update-tools    // 热更插件目录

运行指引

一、初始化

  1. 进入 热更插件目录 执行 npm i 命令进行初始化插件

二、运行(以 android 为例)

  1. 使用 Cocos Creator 2.4.9 打开该项目

  2. 服务器

    1. 使用本地服务器

      • 下载nodejs并安装,windows 可能需要配置好环境变量
      • 执行 cmd 命令 npm i http-server -g 安装 http-server,mac用户要用sudo安装
      • windows 用户执行脚本
      • mac 用户执行脚本
      • 替换 GameConst.ts 中的ip为自己设备ip
      • 替换 subGameConfig.json 中的ip为自己设备ip
    2. 使用远程服务器查看 GameConst.ts 中的 server_ip 引用自行修改逻辑

  3. 构建项目【项目->构建发布->发布平台选 android->配置参照以下->构建】谨记不要勾选MD5

  4. 热更插件操作

    1. 打开热更插件【项目->热更新工具】,打开后热更工具会进行初始化

    2. 修改资源服务器 url

    3. 检查主包配置、子游戏配置。缺少子游戏,请检查是否配置了 bundle,配置好后 点击刷新子游戏按钮,点击下拉菜单,选择对应子游戏后,配置好后点击添加配置按钮

    4. 点击生成热更包按钮,如果子游戏很多,文件很多,可能会有延时,如无报错,等待即可

    5. 点击导入manifest按钮

  5. 构建项目【项目->构建发布->构建】

  6. 删除构建目录下[项目目录]\build\jsb-link\assets不在包内的子游戏文件夹。或者点击热更插件中的生成热更包按钮会自动删除不在包内的子游戏文件夹

  7. 编译

    1. 配置原生开发环境

    2. cocos 自带

      1. 编译项目【项目->构建发布->编译】

      2. 安装 apk(一般在 [项目目录]\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\outputs\apk\debug )

    3. android studio 自行搜索教程

  8. 运行, 如果成功运行,如下,点击 game2 会进行下载,下载完成后点击即可运行

添加游戏指引(以本地服务器为例)

  1. 添加游戏文件夹,配置为bundle,在文件夹中新建与bundle同名启动场景,之所以同名详见子游戏启动逻辑,如有需要可修改改逻辑

  2. 构建项目【项目->构建发布->构建】

  3. 添加热更配置

    1. 打开热更工具面板

    2. 点击刷新子游戏按钮下拉栏选择刚刚添加的子游戏,去掉包内勾选,点击添加配置按钮

  4. 点击生成热更包按钮,如果子游戏很多,文件很多,可能会有延时,如无报错,等待即可

  5. 服务器

    1. 使用本地服务器无需任何操作

    2. 使用远程服务器需要把最新版本替换至远程服务器

  6. 服务器配置中添加新子游戏配置

  7. 重启 app,或者点击其中一个子游戏后回到大厅,成功如下,点击 game3 会进行下载,下载完成后点击即可运行

主包更新指引

  1. 修改主包中 hall 场景内容,比如修改为 hall1

  2. 构建项目【项目->构建发布->构建】

  3. 主包配置中的热更版本+1

  4. 点击生成热更包按钮,如果子游戏很多,文件很多,可能会有延时,如无报错,等待即可

  5. 服务器

    1. 使用本地服务器无需任何操作

    2. 使用远程服务器需要把最新版本替换至远程服务器

  6. 重启 app,运行如下

子包更新指引

  1. 修改子包中 game1 场景内容,比如修改为 game11

  2. 构建项目【项目->构建发布->构建】

  3. 子包 game1 配置中的热更版本+1

  4. 点击生成热更包按钮,如果子游戏很多,文件很多,可能会有延时,如无报错,等待即可

  5. 服务器

    1. 使用本地服务器无需任何操作

    2. 使用远程服务器需要把最新版本替换至远程服务器

  6. 重启 app,或者点击其中一个子游戏后回到大厅,成功如下,点击 game1 会进行下载,下载完成后点击即可运行

注意事项!!!!

  1. 子游戏命名(文件夹名/bundle 名)最好不要包含特殊符号,否则可能导致启动失败

  2. 构建时请不要勾选 MD5

  3. 编译前切记删除构建目录下[项目目录]\build\jsb-link\assets不在包内的子游戏文件夹。

  4. 添加游戏务必配置为 bundle

  5. bundle 间尽量避免相互引用,公共资源放在主包中

hotupdate-panel-description's People

Contributors

xeroo0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.