7d2db19650ec9e2dc4b1d2fa3962916ae5a5bf11.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, LabelNumber, _dec, _dec2, _class, _class2, _descriptor, _crd, ccclass, property, menu, LabelChange;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfLabelNumber(extras) {
  8. _reporterNs.report("LabelNumber", "./LabelNumber", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. _decorator = _cc._decorator;
  18. }, function (_unresolved_2) {
  19. LabelNumber = _unresolved_2.default;
  20. }],
  21. execute: function () {
  22. _crd = true;
  23. _cclegacy._RF.push({}, "fff0fLwVNhNe59VirWTCPFJ", "LabelChange", undefined);
  24. /*
  25. * @Author: dgflash
  26. * @Date: 2022-04-14 17:08:01
  27. * @LastEditors: dgflash
  28. * @LastEditTime: 2023-08-11 10:00:51
  29. */
  30. __checkObsolete__(['_decorator']);
  31. ({
  32. ccclass,
  33. property,
  34. menu
  35. } = _decorator);
  36. /** 数值变化动画标签组件 */
  37. _export("LabelChange", LabelChange = (_dec = ccclass("LabelChange"), _dec2 = menu('OopsFramework/Label/LabelChange (数值变化动画标签)'), _dec(_class = _dec2(_class = (_class2 = class LabelChange extends (_crd && LabelNumber === void 0 ? (_reportPossibleCrUseOfLabelNumber({
  38. error: Error()
  39. }), LabelNumber) : LabelNumber) {
  40. constructor() {
  41. super(...arguments);
  42. _initializerDefineProperty(this, "isInteger", _descriptor, this);
  43. this.duration = 0;
  44. // 持续时间
  45. this.callback = void 0;
  46. // 完成回调
  47. this.isBegin = false;
  48. // 是否开始
  49. this.speed = 0;
  50. // 变化速度
  51. this.end = 0;
  52. }
  53. // 最终值
  54. /**
  55. * 变化到某值,如果从当前开始的begin传入null
  56. * @param {number} duration
  57. * @param {number} end
  58. * @param {Function} [callback]
  59. */
  60. changeTo(duration, end, callback) {
  61. if (duration == 0) {
  62. if (callback) callback();
  63. return;
  64. }
  65. this.playAnim(duration, this.num, end, callback);
  66. }
  67. /**
  68. * 变化值,如果从当前开始的begin传入null
  69. * @param {number} duration
  70. * @param {number} value
  71. * @param {Function} [callback]
  72. * @memberof LabelChange
  73. */
  74. changeBy(duration, value, callback) {
  75. if (duration == 0) {
  76. if (callback) callback();
  77. return;
  78. }
  79. this.playAnim(duration, this.num, this.num + value, callback);
  80. }
  81. /** 立刻停止 */
  82. stop(excCallback) {
  83. if (excCallback === void 0) {
  84. excCallback = true;
  85. }
  86. this.num = this.end;
  87. this.isBegin = false;
  88. if (excCallback && this.callback) this.callback();
  89. }
  90. /** 播放动画 */
  91. playAnim(duration, begin, end, callback) {
  92. this.duration = duration;
  93. this.end = end;
  94. this.callback = callback;
  95. this.speed = (end - begin) / duration;
  96. this.num = begin;
  97. this.isBegin = true;
  98. }
  99. /** 是否已经结束 */
  100. isEnd(num) {
  101. if (this.speed > 0) {
  102. return num >= this.end;
  103. } else {
  104. return num <= this.end;
  105. }
  106. }
  107. update(dt) {
  108. if (this.isBegin) {
  109. if (this.num == this.end) {
  110. this.isBegin = false;
  111. if (this.callback) this.callback();
  112. return;
  113. }
  114. var num = this.num + dt * this.speed;
  115. if (this.isInteger) {
  116. if (this.end < this.num) {
  117. num = Math.floor(num);
  118. } else {
  119. num = Math.ceil(num);
  120. }
  121. }
  122. /** 变化完成 */
  123. if (this.isEnd(num)) {
  124. num = this.end;
  125. this.isBegin = false;
  126. if (this.callback) this.callback();
  127. }
  128. this.num = num;
  129. }
  130. }
  131. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "isInteger", [property], {
  132. configurable: true,
  133. enumerable: true,
  134. writable: true,
  135. initializer: function initializer() {
  136. return false;
  137. }
  138. })), _class2)) || _class) || _class));
  139. _cclegacy._RF.pop();
  140. _crd = false;
  141. }
  142. };
  143. });
  144. //# sourceMappingURL=7d2db19650ec9e2dc4b1d2fa3962916ae5a5bf11.js.map