CocosClass.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const h = t("App");
  6. (cc.ProgressBar.prototype.stopRunToAction = function () {
  7. this.__cbRunToAction && (this.unschedule(this.__cbRunToAction), (this.__cbRunToAction = null));
  8. }),
  9. (cc.ProgressBar.prototype.runTo = function (a, n, r = !1) {
  10. var l = this;
  11. return new Promise(function (e) {
  12. var i,
  13. s,
  14. t,
  15. o = l.progress;
  16. a != o
  17. ? isNaN(a) ||
  18. (0 == n || isNaN(n)
  19. ? ((l.progress = a), e())
  20. : ((i = a > l.progress),
  21. l.stopRunToAction(),
  22. (s = (a - o) / n),
  23. (t = function (t) {
  24. o += s * t;
  25. t = i ? a <= o : o <= a;
  26. (l.progress = r ? Math.abs(o) - Math.floor(Math.abs(o)) : o.limit(0, 1)),
  27. t &&
  28. ((t = a),
  29. r && (t = Math.abs(t) - Math.floor(Math.abs(t))),
  30. (l.progress = t),
  31. l.unscheduleAllCallbacks(),
  32. e());
  33. }),
  34. l.schedule(t, 0, cc.macro.REPEAT_FOREVER),
  35. (l.__cbRunToAction = t)))
  36. : e();
  37. });
  38. }),
  39. (cc.Label.prototype.numberTo = function (t, e, i, s) {
  40. var o,
  41. a,
  42. n = this,
  43. r = null == t ? parseInt(this.string) : t;
  44. (r = isNaN(r) ? 0 : r) != e &&
  45. ((this.string = s ? s(r) : r + ""),
  46. (o = (e - r) / i),
  47. (a = r < e),
  48. this.stopNumberAction(),
  49. (this.__cbNumberTo = i =
  50. function (t) {
  51. (r += o * t),
  52. (n.string = s ? s(r) : r + ""),
  53. a != r < e && (n.unscheduleAllCallbacks(), (n.string = s ? s(e) : e + ""));
  54. }),
  55. this.schedule(i, 0, cc.macro.REPEAT_FOREVER));
  56. }),
  57. (cc.Label.prototype.stopNumberAction = function () {
  58. this.__cbNumberTo && (this.unschedule(this.__cbNumberTo), (this.__cbNumberTo = null));
  59. }),
  60. (cc.Label.prototype.timeCounter = function (t, e = 1, i, s, o) {
  61. var a = this;
  62. (t /= 1e3), (this.string = i ? i(t) : t + ""), this.stopTimeCounterAction();
  63. var n,
  64. r = h.default.DateUtils.Now(),
  65. l = function () {
  66. (n = Math.round(t - (h.default.DateUtils.Now() - r) / 1e3)),
  67. (a.string = i ? i(n) : n + ""),
  68. o && o(n),
  69. n <= 0 && (s && s(), a.unschedule(l));
  70. };
  71. return (this.__cbTimeCounter = l), this.schedule(l, e, cc.macro.REPEAT_FOREVER), l(), l;
  72. }),
  73. (cc.Label.prototype.stopTimeCounterAction = function () {
  74. this.__cbTimeCounter && (this.unschedule(this.__cbTimeCounter), (this.__cbTimeCounter = null));
  75. });