Commit a0c9979c authored by 李维's avatar 李维

真.进度条

parent 54efb15a
......@@ -861,35 +861,27 @@ export default class NewClass extends middleLayerBase {
}
this.isShowWaiting = true;
// 隐藏加载页
const laodingLayer = cc.find('middleLayer/loadingLayer');
laodingLayer.active = true;
const loading = cc.find('middleLayer/loadingLayer/loading');
// 跳小兔子
const loading = cc.find('middleLayer/loadingLayer/loading');
const anim = loading.getComponent(cc.Animation)
anim.play('loading')
// 重置进度条
const script = cc.find('middleLayer/loadingLayer/progress').getComponent('progressScript');
script.setProgress(0);
const changeObj = { value: 0 };
this.showWaitingIntervalId = setInterval(() => {
script.setProgress(changeObj.value);
}, 1);
cc.tween(changeObj)
.to(5, { value: 0.9 })
.call(() => {
clearInterval(this.showWaitingIntervalId);
})
.start();
// 清零进度
const progressTextCom = cc.find("middleLayer/loadingLayer/pText").getComponent(cc.Label)
progressTextCom.string = "0%"
}
hideWaitingLetters() {
cc.find('middleLayer/loadingLayer').active = false;
this.isShowWaiting = false;
if (this.showWaitingIntervalId) {
clearInterval(this.showWaitingIntervalId);
}
}
data: any = {};
......
......@@ -236,7 +236,11 @@ export abstract class middleLayerBase extends cc.Component {
}
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.courseOpenTimeStamp = Date.now();
......@@ -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() {
const setParentVisible = (n) => {
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