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

优化进度条

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