cocos creator大厅、子游戏实现方案

参考cocos论坛:http://forum.cocos.com/t/1-5-2-demo/48200 
demo: https://github.com/zhangjiangyi/HallAndChild 
主要的是实现下载子游戏、跳转到子游戏,然后由子游戏返回到大厅。

我们知道、在启动cocos工程的时候,首先要加载main.js文件,加载准备工作,执行一些配置操作。而由大厅跳转到子游戏的话我们是否需要知道子游戏的配置文件setting.js跟main.js。然后由大厅跳转到子游戏的话其实就是获取子游戏的main.js文件就行了。

首先就是要用热更新的方式下载子游戏。但是热更新下载子游戏的话需要project.manifest文件跟远程文件做对比,但是一开始的时候是子游戏是空空如也的,那就只能用远程的方式获取project.manifest文件,然后进行热更新了。
 

checkUpdate: function () {
        let UIRLFILE = "http://192.168.92.59/update/remote-assets";
        let remoteManifestUrl = this._storagePath + "/project.manifest";
        this.manifestUrl = remoteManifestUrl;

        let customManifestStr = JSON.stringify({
            "packageUrl": UIRLFILE,
            "remoteManifestUrl": UIRLFILE + "/project.manifest",
            "remoteVersionUrl": UIRLFILE + "/version.manifest",
            "version": "1.0.0.0",
            "assets": {},
            "searchPaths": []
        });

        this._checkListener = new jsb.EventListenerAssetsManager(this._am, this.checkCb.bind(this));
        cc.eventManager.addListener(this._checkListener, 1);

        if (this._am.getState() === jsb.AssetsManager.State.UNINITED) {
            if (jsb.fileUtils.isFileExist(remoteManifestUrl)) {
                console.log('加载本地Manifest');
                this._am.loadLocalManifest(this.manifestUrl);
            } else {
                console.log('加载网络Manifest');
                let manifest = new jsb.Manifest(customManifestStr, this._storagePath);
                this._am.loadLocalManifest(manifest, this._storagePath);
            }
        }
        this.prmopt.string = '正在检查版本信息';
        this._am.checkUpdate();
    },

 https://blog.csdn.net/a641832648/article/details/79451030(请跳转)
--------------------- 
作者:Burnner 
来源:CSDN 
原文:https://blog.csdn.net/a641832648/article/details/79451030 
版权声明:本文为博主原创文章,转载请附上博文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值