waitView.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { _decorator, Component, Node, Label } from 'cc';
  2. import { GameMng } from '../GameMng';
  3. import GBaseUI from '../gcommon/GBaseUI';
  4. import { UIButton } from '../gcommon/UIButton';
  5. import { UIManager } from '../gcommon/UIManager';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('waitView')
  8. export class waitView extends GBaseUI {
  9. @property(Label)
  10. lab_des: Node = null;
  11. @property(Node) btn_cancel:Node = null
  12. @property(Node) lab_loading:Node = null
  13. @property(Node) sp_loading:Node = null
  14. static dialog_des:string = null;
  15. static _cancel_call:any = false;
  16. private status_string = ["。","。。","。。。"]
  17. private status_count = 0;
  18. private time_count:number = 0;
  19. start() {
  20. UIButton.BindClick(this.btn_cancel,()=>{
  21. if(waitView._cancel_call){
  22. waitView._cancel_call()
  23. }
  24. },this)
  25. this.schedule(this.dt,0.01)
  26. }
  27. onDestroy(){
  28. this.unschedule(this.dt)
  29. }
  30. static Show(waitText:string,cancel_cllback:any=null){
  31. waitView.dialog_des = waitText;
  32. waitView._cancel_call = cancel_cllback;
  33. UIManager.AddPrefab(GameMng.Instance.uiWaitView);
  34. }
  35. dt(){
  36. this.sp_loading.angle = this.sp_loading.angle+2
  37. }
  38. update(deltaTime: number) {
  39. // this.time_count+=deltaTime;
  40. // if(this.time_count>0.5){
  41. // this.time_count = 0;
  42. // if(this.status_count>=this.status_string.length){
  43. // this.status_count = 0;
  44. // }
  45. // this.lab_loading.getComponent(Label).string = this.status_string[this.status_count]
  46. // this.status_count++;
  47. // }
  48. if(waitView.dialog_des){
  49. if(waitView._cancel_call){
  50. // this.btn_cancel.active = true;
  51. }
  52. this.lab_des.getComponent(Label).string = waitView.dialog_des;
  53. waitView.dialog_des = null;
  54. }
  55. }
  56. }