| 123456789101112131415161718192021222324252627282930313233 |
- cc.Class({
- extends: cc.Component,
- properties: {
- ProgressBar: {
- default: null,
- type: cc.Node,
- serializable: true,
- }
- },
- SetProgressBar(RemainTime,TotalTime)
- {
- this.node.getComponent(cc.Label).string = this.CastSecondsToHours(RemainTime);
- this.ProgressBar.getComponent(cc.ProgressBar).progress = RemainTime/TotalTime;
- },
- CastSecondsToHours(Time)
- {
- if(Time<60) return Math.floor(Time)+'秒';
- if(Time<3600 && Time >=60)
- {
- return Math.floor(Time/60)+'分'+Math.floor(Time%60)+'秒';
- }
- if(Time>=3600)
- {
- let Hour = Math.floor(Time/3600);
- let s = Time%3600;
- let Min = Math.floor(s/60);
- return Math.floor(Hour)+'小时'+Math.floor(Min)+'分';
- }
- return Math.floor(Time/3600);
- },
- });
|