LoadingView.ts 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { _decorator, Component, Node, ProgressBarComponent, LabelComponent } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('LoadingView')
  4. export class LoadingView extends Component {
  5. @property(ProgressBarComponent)
  6. pregressBar:ProgressBarComponent = null;
  7. @property(LabelComponent)
  8. label: LabelComponent = null;
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad () {
  11. LoadingView.instance=this;
  12. }
  13. start () {
  14. // this.label.string="";
  15. }
  16. // update (dt) {}
  17. /**
  18. * 更新进度
  19. * @param progress
  20. */
  21. UpdateProgress(progress:number):void{
  22. this.pregressBar.progress=progress;
  23. }
  24. /**
  25. * 更新文本
  26. * @param label
  27. */
  28. UpdateLabel(label:string):void{
  29. this.label.string=label;
  30. }
  31. Show():void{
  32. this.node.active=true;
  33. }
  34. Hide():void{
  35. this.node.active=false;
  36. }
  37. private static instance:LoadingView;
  38. public static get single(){
  39. return this.instance;
  40. }
  41. }