CustomLoading.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor:function(){
  6. this.m_bFirstShow = true;
  7. },
  8. OnShowView:function(){
  9. this.m_EndTime = null;
  10. if(this.m_bFirstShow)this.schedule(this.OnCheck, 1);
  11. this.SetWorkStr('加載中');
  12. this.m_bFirstShow = false;
  13. },
  14. OnHideView:function(){
  15. this.m_EndTime = null;
  16. if(this.node) this.node.active = false;
  17. },
  18. SetWorkStr:function(str){
  19. if(this.m_LbWork == null) this.m_LbWork = this.$('LbWork@Label');
  20. this.m_strWork = str;
  21. this.m_PtCnt = 0;
  22. this.OnCheck();
  23. },
  24. SetOverTime:function(time){
  25. this.m_DelayTime = time;
  26. if(time == null || time <= 0) return;
  27. this.m_EndTime = new Date().getTime() + this.m_DelayTime*1000;
  28. },
  29. OnCheck:function() {
  30. if(this.m_EndTime == null) return
  31. if(this.m_LbWork){
  32. this.m_LbWork.string = this.m_strWork;
  33. for(var i=0;i<this.m_PtCnt;i++) this.m_LbWork.string += '.';
  34. if(this.m_PtCnt++ >= 3) this.m_PtCnt = 0;
  35. }
  36. var Now = new Date().getTime();
  37. if( this.m_EndTime - Now <= 0){
  38. if(this.m_Hook)this.m_Hook.LoadingOver();
  39. this.m_EndTime = Now + this.m_DelayTime*1000;
  40. }
  41. },
  42. });