EasyLoading.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. e =
  5. (this && this.__decorate) ||
  6. function (t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", {value: !0}), (i.EasyLoading = void 0);
  17. const o = t("App"),
  18. {ccclass: s, property: a} = cc._decorator;
  19. t = class extends cc.Component {
  20. constructor() {
  21. super(...arguments),
  22. (this.tween = null),
  23. (this.loadReel = null),
  24. (this.bg = null),
  25. (this.touchNode = null),
  26. (this.count = 0);
  27. }
  28. onLoad() {
  29. (this.tween = cc.tween(this.loadReel).by(2, {angle: 360}).repeatForever()),
  30. (this.node.active = !1),
  31. cc.game.addPersistRootNode(this.node),
  32. ((o.default.EasyLoading = this).count = 0);
  33. }
  34. init() {}
  35. showLoading(t = !0) {
  36. this.count++,
  37. (this.node.active = !0),
  38. t
  39. ? (this.tween.start(), (this.loadReel.active = !0), (this.bg.enabled = !0))
  40. : ((this.loadReel.active = !1), (this.bg.enabled = !1));
  41. }
  42. showLoadingByTime(t = 0, e, i, s = !0) {
  43. this.showLoading(s),
  44. o.default.TimerManager.doTimer(1e3, t, this.loadingByTimeUpdate, this, () => {
  45. e && e.apply(i), this.hideLoadingByTime();
  46. });
  47. }
  48. hideLoading() {
  49. this.count--,
  50. this.count <= 0 &&
  51. ((this.count = 0),
  52. this.loadReel.stopAllActions(),
  53. (this.node.active = !1),
  54. o.default.TimerManager.remove(this.loadingByTimeUpdate, this));
  55. }
  56. hideLoadingByTime() {
  57. this.hideLoading();
  58. }
  59. loadingByTimeUpdate() {}
  60. showLoadingTouchEnd(t) {
  61. t &&
  62. (this.count++,
  63. (this.node.active = !0),
  64. (this.loadReel.active = !1),
  65. (this.bg.enabled = !1),
  66. (this.callBack = t),
  67. this.touchNode.on(cc.Node.EventType.TOUCH_START, this.callBack, this));
  68. }
  69. hideLoadingTouchEnd() {
  70. this.count--,
  71. this.count <= 0 &&
  72. ((this.count = 0),
  73. this.loadReel.stopAllActions(),
  74. (this.node.active = !1),
  75. o.default.TimerManager.remove(this.loadingByTimeUpdate, this)),
  76. this.callBack &&
  77. (this.touchNode.off(cc.Node.EventType.TOUCH_START, this.callBack, this), (this.callBack = null));
  78. }
  79. };
  80. e([a(cc.Node)], t.prototype, "loadReel", void 0),
  81. e([a(cc.Sprite)], t.prototype, "bg", void 0),
  82. e([a(cc.Node)], t.prototype, "touchNode", void 0),
  83. (t = e([s], t)),
  84. (i.EasyLoading = t);