cc.Class({ extends: cc.Component, properties: { // manifestUrl: cc.RawAsset, preloadProgress: cc.ProgressBar, preloadLabel: cc.Label, updateUI: cc.Node, _updating: false, //是否正在更新 _canRetry: false, //能否重新获取更新 _preloaded: false, //是否已经预加载完资源 }, onLoad () { }, init () { if(cc.sys.platform === cc.sys.WECHAT_GAME) { this.updateUI.active = true; let dis = 0.012 this.timeCtrl = () => { if(parseInt(this.preloadProgress.progress) == 1) { this._preloaded = true; this.unschedule(this.timeCtrl) } else { dis = dis < 0.002 ? 0.002 : dis - 0.0001; this.preloadProgress.progress += dis } this.preloadLabel.string = '加载中,请稍候...' + (this.preloadProgress.progress * 100).toFixed(0) + '%' } this.schedule(this.timeCtrl, 0.03) } else { this.updateUI.active = false; } }, /** * 预加载结束 */ endPreload () { this.preloadProgress.progress = 1; this.scheduleOnce(() => { this.updateUI.active = false; }, 0.5) }, onDestroy () { }, start () { }, // update (dt) {}, });