Commit 0375cd6c authored by 李维's avatar 李维

优化进度条

parent e898f71c
......@@ -245,7 +245,6 @@ export abstract class middleLayerBase extends cc.Component {
bundle.loadScene(sceneName, null, (finish, total, item) => {
this.setLoadingProgressBar(Math.floor(finish / total * 100));
}, (err, scene) => {
this.setLoadingProgressBar(0);
this.courseOpenTimeStamp = Date.now();
cc.director.runScene(scene, null, () => {
console.log('sceneName = ' + sceneName);
......
......@@ -13,6 +13,9 @@ export default class ProgressClass extends cc.Component {
@property(cc.Node)
bar: cc.Node = null;
@property(cc.Integer)
maxWidth: cc.Integer = 100;
@property(cc.Node)
process: cc.Node = null;
......@@ -21,25 +24,14 @@ export default class ProgressClass extends cc.Component {
}
barBaseW = null;
barSpr = null;
barSf = null;
init() {
this.barBaseW = this.bar.width;
this.barSpr = this.bar.getComponent(cc.Sprite);
this.barSf = this.barSpr.spriteFrame;
this.setProgress(0);
}
setProgress(progress) {
if (!this.barSf) {
return;
}
const w = this.barBaseW * progress;
const rect = this.barSf.getRect();
rect.width = w;
this.bar.width = w;
this.barSpr.spriteFrame.setRect(rect);
const scale = progress <= 1 ? progress : 1;
this.bar.width = this.maxWidth * scale;
// console.log(this.bar.width)
}
onEnable() {
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 1400,
......@@ -26,10 +26,10 @@
"height": 46,
"rawWidth": 1400,
"rawHeight": 102,
"borderTop": 0,
"borderTop": 6,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"borderLeft": 24,
"borderRight": 44,
"subMetas": {}
}
}
......
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