update
This commit is contained in:
@@ -1,56 +1,55 @@
|
||||
import { _decorator, Component, Label, ProgressBar } from 'cc'
|
||||
import { Component, Label, ProgressBar, _decorator } from 'cc'
|
||||
|
||||
const { ccclass, property } = _decorator
|
||||
|
||||
@ccclass('Progress')
|
||||
export default class Progress extends Component {
|
||||
@property(Label)
|
||||
public percentLable: Label
|
||||
@property(Label)
|
||||
public percentLable: Label
|
||||
|
||||
@property(ProgressBar)
|
||||
public bar: ProgressBar
|
||||
@property(ProgressBar)
|
||||
public bar: ProgressBar
|
||||
|
||||
onLoad() {
|
||||
this.bar.node.active = false
|
||||
this.bar.progress = 0
|
||||
}
|
||||
onLoad() {
|
||||
this.bar.node.active = false
|
||||
this.bar.progress = 0
|
||||
}
|
||||
|
||||
start() {}
|
||||
start() {}
|
||||
|
||||
updatePercent(current, filePercent) {
|
||||
//this.percentLable.string = filePercent.toFixed(2);
|
||||
}
|
||||
updatePercent(current, filePercent) {
|
||||
// this.percentLable.string = filePercent.toFixed(2);
|
||||
}
|
||||
|
||||
updatefileTotal(current, filePercent) {
|
||||
if (!this.bar.node.active) this.bar.node.active = true
|
||||
var nowPercent = Math.round((current / filePercent) * 100)
|
||||
var curMB = this.getMB(current)
|
||||
var totalMB = this.getMB(filePercent)
|
||||
// this.percentLable.string = "正在更新 " + nowPercent + "%" + " ( " + curMB + " / "+totalMB +" MB)";
|
||||
nowPercent = Math.min(nowPercent, 100)
|
||||
this.percentLable.string = '正在更新 ' + nowPercent + '%'
|
||||
var percent = current / filePercent
|
||||
this.bar.progress = percent
|
||||
}
|
||||
updatefileTotal(current: number, filePercent: number) {
|
||||
if (!this.bar.node.active) this.bar.node.active = true
|
||||
let nowPercent = Math.round((current / filePercent) * 100)
|
||||
const curMB = this.getMB(current)
|
||||
const totalMB = this.getMB(filePercent)
|
||||
// this.percentLable.string = "正在更新 " + nowPercent + "%" + " ( " + curMB + " / "+totalMB +" MB)";
|
||||
nowPercent = Math.min(nowPercent, 100)
|
||||
this.percentLable.string = `正在更新 ${nowPercent}%`
|
||||
this.bar.progress = current / filePercent
|
||||
}
|
||||
|
||||
public updateProgress(
|
||||
current,
|
||||
total,
|
||||
msg: string = '正在加载资源,此过程不消耗流量...'
|
||||
) {
|
||||
this.bar.node.active = true
|
||||
// this.setMsg(msg+ current + "/" + total);
|
||||
this.setMsg(msg)
|
||||
this.bar.progress = current / total
|
||||
}
|
||||
public updateProgress(
|
||||
current: number,
|
||||
total: number,
|
||||
msg: string = '正在加载资源,此过程不消耗流量...',
|
||||
) {
|
||||
this.bar.node.active = true
|
||||
// this.setMsg(msg+ current + "/" + total);
|
||||
this.setMsg(msg)
|
||||
this.bar.progress = current / total
|
||||
}
|
||||
|
||||
getMB(bytes) {
|
||||
bytes /= 1024
|
||||
bytes /= 1024
|
||||
return bytes.toFixed(2)
|
||||
}
|
||||
getMB(bytes: number) {
|
||||
bytes /= 1024
|
||||
bytes /= 1024
|
||||
return bytes.toFixed(2)
|
||||
}
|
||||
|
||||
public setMsg(msg: string = '游戏加载中,请稍后...') {
|
||||
this.percentLable.string = msg
|
||||
}
|
||||
public setMsg(msg: string = '游戏加载中,请稍后...') {
|
||||
this.percentLable.string = msg
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user