LoadingUI.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { _decorator,Component,director,Label, ProgressBar } from 'cc';
  2. import { UIBase } from '../GameFrameWork/UIBase';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('LoadingUI')
  5. // export class LoadingUI extends UIBase {
  6. // progressBar: ProgressBar = null;
  7. // progressLabel: Label = null;
  8. // whichRes: Label = null;
  9. // protected onStart(): void {
  10. // this.progressBar = this.getComponentInChildren(ProgressBar);
  11. // this.progressLabel = this.getComponentInChildren(Label);
  12. // this.whichRes = this.getLabel("_which");
  13. // }
  14. // public updateProgress(progress: number){
  15. // if(this.progressBar){
  16. // this.progressBar.progress = progress;
  17. // }
  18. // if(this.progressLabel){
  19. // this.progressLabel.string = `${Math.floor(progress * 100)}%`;
  20. // }
  21. // }
  22. // public updateWhichRes(which: number){
  23. // if(this.whichRes){
  24. // this.whichRes.string = `${which}/2`;
  25. // }
  26. // }
  27. // }
  28. export class LoadingUI extends Component {
  29. progressBar: ProgressBar = null;
  30. progressLabel: Label = null;
  31. whichRes: Label = null;
  32. protected start(): void {
  33. this.progressBar = this.getComponentInChildren(ProgressBar);
  34. this.progressLabel = this.getComponentInChildren(Label);
  35. this.whichRes = this.node.getChildByName("_which").getComponent(Label);
  36. }
  37. public updateProgress(progress: number){
  38. if(this.progressBar){
  39. this.progressBar.progress = progress;
  40. }
  41. if(this.progressLabel){
  42. this.progressLabel.string = `${Math.floor(progress * 100)}%`;
  43. }
  44. }
  45. public updateWhichRes(which: number){
  46. if(this.whichRes){
  47. this.whichRes.string = `${which}/2`;
  48. }
  49. }
  50. }