Commit a0c9979c authored by 李维's avatar 李维

真.进度条

parent 54efb15a
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -861,35 +861,27 @@ export default class NewClass extends middleLayerBase { ...@@ -861,35 +861,27 @@ export default class NewClass extends middleLayerBase {
} }
this.isShowWaiting = true; this.isShowWaiting = true;
// 隐藏加载页
const laodingLayer = cc.find('middleLayer/loadingLayer'); const laodingLayer = cc.find('middleLayer/loadingLayer');
laodingLayer.active = true; laodingLayer.active = true;
const loading = cc.find('middleLayer/loadingLayer/loading');
// 跳小兔子
const loading = cc.find('middleLayer/loadingLayer/loading');
const anim = loading.getComponent(cc.Animation) const anim = loading.getComponent(cc.Animation)
anim.play('loading') anim.play('loading')
// 重置进度条
const script = cc.find('middleLayer/loadingLayer/progress').getComponent('progressScript'); const script = cc.find('middleLayer/loadingLayer/progress').getComponent('progressScript');
script.setProgress(0); script.setProgress(0);
const changeObj = { value: 0 }; // 清零进度
this.showWaitingIntervalId = setInterval(() => { const progressTextCom = cc.find("middleLayer/loadingLayer/pText").getComponent(cc.Label)
script.setProgress(changeObj.value); progressTextCom.string = "0%"
}, 1);
cc.tween(changeObj)
.to(5, { value: 0.9 })
.call(() => {
clearInterval(this.showWaitingIntervalId);
})
.start();
} }
hideWaitingLetters() { hideWaitingLetters() {
cc.find('middleLayer/loadingLayer').active = false; cc.find('middleLayer/loadingLayer').active = false;
this.isShowWaiting = false; this.isShowWaiting = false;
if (this.showWaitingIntervalId) {
clearInterval(this.showWaitingIntervalId);
}
} }
data: any = {}; data: any = {};
......
...@@ -236,7 +236,11 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -236,7 +236,11 @@ export abstract class middleLayerBase extends cc.Component {
} }
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => { cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
bundle.loadScene(sceneName, null, null, (err, scene) => { bundle.loadScene(sceneName, null, (finish, total, item) => {
this.setLoadingProgressBar(Math.floor(finish / total * 100));
}, (err, scene) => {
this.loadBundleLock = false; // 加载完成 解锁 this.loadBundleLock = false; // 加载完成 解锁
this.courseOpenTimeStamp = Date.now(); this.courseOpenTimeStamp = Date.now();
...@@ -270,6 +274,21 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -270,6 +274,21 @@ export abstract class middleLayerBase extends cc.Component {
}); });
} }
progressTextCom = null;
progressBarScript = null;
setLoadingProgressBar(pInt) {
if(!this.progressTextCom) {
this.progressTextCom = cc.find("middleLayer/loadingLayer/pText").getComponent(cc.Label)
}
if(!this.progressBarScript) {
this.progressBarScript = cc.find('middleLayer/loadingLayer/progress').getComponent('progressScript');
}
this.progressTextCom.string = `${pInt}%`;
this.progressBarScript.setProgress(pInt / 100);
}
setNodeListVisible() { setNodeListVisible() {
const setParentVisible = (n) => { const setParentVisible = (n) => {
n.active = true; n.active = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment