6fc8a3b9-62f7-4b58-bba7-161c92b6c23c.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. "use strict";
  2. cc._RF.push(module, '6fc8aO5YvdLWLunFhyStsI8', 'QMoveAction');
  3. // scripts/Framework/QMoveAction.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var QEasing_1 = require("./QEasing");
  26. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  27. var QMoveAction = /** @class */ (function (_super) {
  28. __extends(QMoveAction, _super);
  29. function QMoveAction() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. _this.delay = 0;
  32. _this.delPos = cc.Vec2.ZERO;
  33. _this.duration = 0;
  34. _this.interval = 0;
  35. _this.loop = false;
  36. _this.revert = false;
  37. _this._tween = null;
  38. _this._originPos = cc.Vec3.ZERO;
  39. return _this;
  40. }
  41. QMoveAction.prototype.onLoad = function () {
  42. var _this = this;
  43. this._originPos = cc.v3(this.node.x, this.node.y);
  44. this.node.position = cc.v3(this._originPos.x - this.delPos.x, this._originPos.y - this.delPos.y);
  45. var widget = this.getComponent(cc.Widget);
  46. if (widget) {
  47. widget.enabled = false;
  48. }
  49. var delayTween = cc.tween().delay(this.delay);
  50. var actionTween = cc.tween();
  51. actionTween.call(function () {
  52. _this.node.position = cc.v3(_this._originPos.x - _this.delPos.x, _this._originPos.y - _this.delPos.y);
  53. });
  54. if (this.revert) {
  55. actionTween.by(this.duration * 0.5, { position: cc.v3(this.delPos.x, this.delPos.y) }, { easing: this._getEase() });
  56. actionTween.by(this.duration * 0.5, { position: cc.v3(-this.delPos.x, -this.delPos.y) }, { easing: this._getEase() });
  57. }
  58. else {
  59. actionTween.by(this.duration, { position: cc.v3(this.delPos.x, this.delPos.y) }, { easing: this._getEase() });
  60. }
  61. actionTween.delay(this.interval);
  62. this._tween = cc.tween(this.node);
  63. this._tween.then(delayTween);
  64. this._tween.then(actionTween);
  65. if (this.loop) {
  66. this._tween.repeatForever();
  67. }
  68. };
  69. QMoveAction.prototype.onEnable = function () {
  70. this.node.position = cc.v3(this._originPos.x - this.delPos.x, this._originPos.y - this.delPos.y);
  71. this._tween.start();
  72. };
  73. __decorate([
  74. property()
  75. ], QMoveAction.prototype, "delay", void 0);
  76. __decorate([
  77. property(cc.Vec2)
  78. ], QMoveAction.prototype, "delPos", void 0);
  79. __decorate([
  80. property()
  81. ], QMoveAction.prototype, "duration", void 0);
  82. __decorate([
  83. property()
  84. ], QMoveAction.prototype, "interval", void 0);
  85. __decorate([
  86. property()
  87. ], QMoveAction.prototype, "loop", void 0);
  88. __decorate([
  89. property()
  90. ], QMoveAction.prototype, "revert", void 0);
  91. QMoveAction = __decorate([
  92. ccclass
  93. ], QMoveAction);
  94. return QMoveAction;
  95. }(QEasing_1.default));
  96. exports.default = QMoveAction;
  97. cc._RF.pop();