cc.Class({ extends: cc.Component, properties: { totalTime: { default: 10 }, }, // ProgressBar.js onLoad () { }, fire(time) { this.node.getComponent(cc.Sprite).fillRange = 1; this.totalTime = time; this.schedule(this.changeProgressBar, 1); }, changeProgressBar () { this.node.getComponent(cc.Sprite).fillRange -= 1/this.totalTime; if (this.node.getComponent(cc.Sprite).fillRange <= 0) { this.unschedule(this.changeProgressBar); this.node.getComponent(cc.Sprite).fillRange = 0; } }, setValue(value) { this.node.getComponent(cc.Sprite).fillRange = value; }, stop() { this.unschedule(this.changeProgressBar); } });