dfcefa4c3af6d47d1429be6953fb6dd37d582e77.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, CCFloat, CCInteger, Component, easing, Enum, tween, Vec3, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _crd, ccclass, property, AnimationType, BounceAnimation;
  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. return {
  8. setters: [function (_cc) {
  9. _cclegacy = _cc.cclegacy;
  10. __checkObsolete__ = _cc.__checkObsolete__;
  11. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  12. _decorator = _cc._decorator;
  13. CCFloat = _cc.CCFloat;
  14. CCInteger = _cc.CCInteger;
  15. Component = _cc.Component;
  16. easing = _cc.easing;
  17. Enum = _cc.Enum;
  18. tween = _cc.tween;
  19. Vec3 = _cc.Vec3;
  20. }],
  21. execute: function () {
  22. _crd = true;
  23. _cclegacy._RF.push({}, "80b6b2umTRJgp27pHM6FB3M", "BounceAnimation", undefined);
  24. __checkObsolete__(['_decorator', 'CCFloat', 'CCInteger', 'Component', 'easing', 'Enum', 'tween', 'Vec3']);
  25. ({
  26. ccclass,
  27. property
  28. } = _decorator);
  29. AnimationType = /*#__PURE__*/function (AnimationType) {
  30. AnimationType[AnimationType["BOUNCE"] = 0] = "BOUNCE";
  31. AnimationType[AnimationType["BREATHE"] = 1] = "BREATHE";
  32. return AnimationType;
  33. }(AnimationType || {});
  34. _export("BounceAnimation", BounceAnimation = (_dec = ccclass('BounceAnimation'), _dec2 = property({
  35. type: Enum(AnimationType),
  36. tooltip: '动画类型'
  37. }), _dec3 = property({
  38. type: CCInteger,
  39. tooltip: '缓动高度',
  40. visible() {
  41. return this.animationType === AnimationType.BOUNCE;
  42. }
  43. }), _dec4 = property({
  44. type: CCInteger,
  45. tooltip: '缓动时间(秒)',
  46. visible() {
  47. return this.animationType === AnimationType.BOUNCE;
  48. }
  49. }), _dec5 = property({
  50. type: CCFloat,
  51. tooltip: '缩放幅度',
  52. visible() {
  53. return this.animationType === AnimationType.BREATHE;
  54. }
  55. }), _dec6 = property({
  56. type: CCInteger,
  57. tooltip: '呼吸周期(秒)',
  58. visible() {
  59. return this.animationType === AnimationType.BREATHE;
  60. }
  61. }), _dec(_class = (_class2 = class BounceAnimation extends Component {
  62. constructor() {
  63. super(...arguments);
  64. _initializerDefineProperty(this, "animationType", _descriptor, this);
  65. //弹跳动画参数
  66. _initializerDefineProperty(this, "bounceHeight", _descriptor2, this);
  67. _initializerDefineProperty(this, "duration", _descriptor3, this);
  68. //呼吸动画参数
  69. _initializerDefineProperty(this, "scaleSize", _descriptor4, this);
  70. _initializerDefineProperty(this, "breatheDuration", _descriptor5, this);
  71. this.originalPosition = new Vec3();
  72. this.originalScale = new Vec3();
  73. }
  74. // 新增原始缩放值记录
  75. start() {
  76. this.originalPosition = this.node.position.clone();
  77. this.originalScale = this.node.scale.clone(); // 记录原始缩放值
  78. this.startAnimation();
  79. }
  80. /**
  81. * 开始执行动画
  82. */
  83. startAnimation() {
  84. var btn_play = this.node;
  85. if (this.animationType === AnimationType.BOUNCE) {
  86. tween(btn_play).delay(Math.random()).to(this.duration, {
  87. position: new Vec3(this.originalPosition.x, this.originalPosition.y + this.bounceHeight, this.originalPosition.z)
  88. }, {
  89. easing: easing.linear
  90. }) // 向上缓动
  91. .to(this.duration, {
  92. position: new Vec3(this.originalPosition.x, this.originalPosition.y - this.bounceHeight, this.originalPosition.z)
  93. }, {
  94. easing: easing.linear
  95. }) // 向下缓动
  96. .to(this.duration, {
  97. position: new Vec3(this.originalPosition.x, this.originalPosition.y, this.originalPosition.z)
  98. }, {
  99. easing: easing.linear
  100. }) // 向下缓动
  101. .union().repeatForever() // 无限循环
  102. .start(); // 启动动画
  103. } else if (this.animationType === AnimationType.BREATHE) {
  104. tween(btn_play).sequence(tween().to(this.breatheDuration, {
  105. scale: new Vec3(this.originalScale.x + this.scaleSize, this.originalScale.y + this.scaleSize, 1)
  106. }), tween().to(this.breatheDuration, {
  107. scale: this.originalScale
  108. })).repeatForever().start();
  109. }
  110. }
  111. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "animationType", [_dec2], {
  112. configurable: true,
  113. enumerable: true,
  114. writable: true,
  115. initializer: function initializer() {
  116. return AnimationType.BOUNCE;
  117. }
  118. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "bounceHeight", [_dec3], {
  119. configurable: true,
  120. enumerable: true,
  121. writable: true,
  122. initializer: function initializer() {
  123. return 20;
  124. }
  125. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "duration", [_dec4], {
  126. configurable: true,
  127. enumerable: true,
  128. writable: true,
  129. initializer: function initializer() {
  130. return 0.5;
  131. }
  132. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "scaleSize", [_dec5], {
  133. configurable: true,
  134. enumerable: true,
  135. writable: true,
  136. initializer: function initializer() {
  137. return 0.05;
  138. }
  139. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "breatheDuration", [_dec6], {
  140. configurable: true,
  141. enumerable: true,
  142. writable: true,
  143. initializer: function initializer() {
  144. return 1;
  145. }
  146. })), _class2)) || _class));
  147. _cclegacy._RF.pop();
  148. _crd = false;
  149. }
  150. };
  151. });
  152. //# sourceMappingURL=dfcefa4c3af6d47d1429be6953fb6dd37d582e77.js.map