123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Vec3, Shake, _crd;
- function get_new_shake(startPos) {
- if (startPos === void 0) {
- startPos = new Vec3(0, 0, 0);
- }
- return new Shake(startPos);
- }
- _export("default", get_new_shake);
- return {
- setters: [function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- Vec3 = _cc.Vec3;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "88adahxArtIPKhtXnEB29+o", "Shake", undefined);
- __checkObsolete__(['Vec3']);
- Shake = class Shake {
- constructor(startPos) {
- if (startPos === void 0) {
- startPos = new Vec3(0, 0, 0);
- }
- this.intensity = void 0;
- this.duration = void 0;
- this.shakePos = new Vec3(0, 0, 0);
- this.startPos = startPos;
- this.duration = 0;
- this.intensity = 0;
- }
- /**改变初起点*/
- setStartPos(x, y) {
- this.startPos.x = x;
- this.startPos.y = y;
- }
- /**开始抖动
- * duration 时间
- * intensity 强度
- */
- start(duration, intensity) {
- if (duration === void 0) {
- duration = 0.3;
- }
- if (intensity === void 0) {
- intensity = 3.8;
- }
- this.duration = duration;
- this.intensity = intensity;
- }
- /**停止抖动*/
- stop() {
- this.shakePos.x = this.startPos.x;
- this.shakePos.y = this.startPos.y;
- this.duration = 0;
- return this.shakePos;
- }
- getShakePos() {
- return this.shakePos;
- }
- action(dt) {
- if (this.duration > 0) {
- this.duration -= dt;
- if (this.duration <= 0) {
- return this.stop();
- } else {
- var randomX = Math.random() * this.intensity - this.intensity * 0.5;
- var randomY = Math.random() * this.intensity - this.intensity * 0.5;
- this.shakePos.x = this.startPos.x + randomX;
- this.shakePos.y = this.startPos.y + randomY;
- return this.shakePos;
- }
- }
- return null;
- }
- };
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=ad64ab55ef68b0e0b1655d625f240b65c0c8851d.js.map
|