判断资源彻底加载完毕

/src/Main.js

调用1

  //资源加载完毕
    p.onComponentsResourceLoad = function () {
        var groups = RES.getGroupByName("components");
        if (groups == null || groups.length == 0) {
            this.onStart();
        }
        else {
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onComponentsResourceLoadComplete, this);
            RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onComponentsResourceLoadError, this);
            RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onComponentsResourceProgress, this);
            RES.loadGroup("components");
        }

        console.log(11)
    };

调用2

 //最后执行
    p.onLimitResourceLoad = function () {
        var groups = RES.getGroupByName("limit");
        if (groups == null || groups.length == 0) {
            this.onComponentsResourceLoad();
        }
        else {
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onLimitResourceLoadComplete, this);
            RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onLimitResourceLoadError, this);
            RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onLimitResourceProgress, this);
            RES.loadGroup("limit");
        }

        console.log(9)
    };

调用3

  //最后执行
    p.onMergeResourceLoadComplete = function (event) {
        RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onMergeResourceLoadComplete, this);
        RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onMergeResourceLoadError, this);
        RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onMergeResourceProgress, this);
        var groups = RES.getGroupByName("resourceMerge");
        if (groups == null || groups.length == 0)
            return;
        for (var i = 0; i < groups.length; i++) {
            var resourceItem = groups[i];
            if (resourceItem.type == "json") {
                var jsonData = RES.getRes(resourceItem.name);
                var imageFile = jsonData.file;
                var imageTexture = RES.getRes(imageFile);
                this.decodeMerge(jsonData, imageTexture);
            }
        }
        this.onLimitResourceLoad();

        console.log(8)
//文件加载完毕之后执行的程序放在这里
    };
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值