ad64ab55ef68b0e0b1655d625f240b65c0c8851d.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Vec3, Shake, _crd;
  4. function get_new_shake(startPos) {
  5. if (startPos === void 0) {
  6. startPos = new Vec3(0, 0, 0);
  7. }
  8. return new Shake(startPos);
  9. }
  10. _export("default", get_new_shake);
  11. return {
  12. setters: [function (_cc) {
  13. _cclegacy = _cc.cclegacy;
  14. __checkObsolete__ = _cc.__checkObsolete__;
  15. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  16. Vec3 = _cc.Vec3;
  17. }],
  18. execute: function () {
  19. _crd = true;
  20. _cclegacy._RF.push({}, "88adahxArtIPKhtXnEB29+o", "Shake", undefined);
  21. __checkObsolete__(['Vec3']);
  22. Shake = class Shake {
  23. constructor(startPos) {
  24. if (startPos === void 0) {
  25. startPos = new Vec3(0, 0, 0);
  26. }
  27. this.intensity = void 0;
  28. this.duration = void 0;
  29. this.shakePos = new Vec3(0, 0, 0);
  30. this.startPos = startPos;
  31. this.duration = 0;
  32. this.intensity = 0;
  33. }
  34. /**改变初起点*/
  35. setStartPos(x, y) {
  36. this.startPos.x = x;
  37. this.startPos.y = y;
  38. }
  39. /**开始抖动
  40. * duration 时间
  41. * intensity 强度
  42. */
  43. start(duration, intensity) {
  44. if (duration === void 0) {
  45. duration = 0.3;
  46. }
  47. if (intensity === void 0) {
  48. intensity = 3.8;
  49. }
  50. this.duration = duration;
  51. this.intensity = intensity;
  52. }
  53. /**停止抖动*/
  54. stop() {
  55. this.shakePos.x = this.startPos.x;
  56. this.shakePos.y = this.startPos.y;
  57. this.duration = 0;
  58. return this.shakePos;
  59. }
  60. getShakePos() {
  61. return this.shakePos;
  62. }
  63. action(dt) {
  64. if (this.duration > 0) {
  65. this.duration -= dt;
  66. if (this.duration <= 0) {
  67. return this.stop();
  68. } else {
  69. var randomX = Math.random() * this.intensity - this.intensity * 0.5;
  70. var randomY = Math.random() * this.intensity - this.intensity * 0.5;
  71. this.shakePos.x = this.startPos.x + randomX;
  72. this.shakePos.y = this.startPos.y + randomY;
  73. return this.shakePos;
  74. }
  75. }
  76. return null;
  77. }
  78. };
  79. _cclegacy._RF.pop();
  80. _crd = false;
  81. }
  82. };
  83. });
  84. //# sourceMappingURL=ad64ab55ef68b0e0b1655d625f240b65c0c8851d.js.map