const { ccclass, property } = cc._decorator;

@ccclass
export default class LoadingBar extends cc.Component {
    @property({ type: cc.Sprite, displayName: '进度条' })
    private bar: cc.Sprite = null;

    private len: number;

    onLoad() {
        this.len = this.bar.node.width;
        this.bar.node.x = -this.len;
    }

    setProgress(current) {
        this.bar.node.x = -this.len + (current / 100 * this.len);
    }
}
