HuawenMoveAni.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s =
  5. (this && this.__decorate) ||
  6. function(t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", { value: !0 });
  17. const { ccclass: o, property: a, menu: n } = cc._decorator;
  18. e = class extends cc.Component {
  19. constructor() {
  20. super(...arguments),
  21. (this.huawen_1 = null),
  22. (this.huawen_2 = null),
  23. (this.targetPos = null),
  24. (this.originPos = null),
  25. (this.speed = 50),
  26. (this.nomal = null);
  27. }
  28. onLoad() {
  29. this.nomal = this.targetPos.sub(this.originPos).normalize();
  30. }
  31. update(t) {
  32. (this.huawen_1.x += t * this.speed * this.nomal.x),
  33. (this.huawen_1.y += t * this.speed * this.nomal.y),
  34. (this.huawen_2.x += t * this.speed * this.nomal.x),
  35. (this.huawen_2.y += t * this.speed * this.nomal.y),
  36. this.huawen_1.x > this.targetPos.x && (this.huawen_1.position = this.originPos),
  37. this.huawen_2.x > this.targetPos.x && (this.huawen_2.position = this.originPos);
  38. }
  39. onTouchClose() {
  40. (this.huawen_1.active = !1), (this.huawen_2.active = !1);
  41. }
  42. };
  43. s([a(cc.Node)], e.prototype, "huawen_1", void 0),
  44. s([a(cc.Node)], e.prototype, "huawen_2", void 0),
  45. s([a(cc.Vec2)], e.prototype, "targetPos", void 0),
  46. s([a(cc.Vec2)], e.prototype, "originPos", void 0),
  47. (e = s([o], e)),
  48. (i.default = e);