05a06ba9-139c-4517-9177-a757350733e1.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. "use strict";
  2. cc._RF.push(module, '05a06upE5xFF5F3p1c1BzPh', 'QTween');
  3. // scripts/Framework/QTween.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. exports.TweenMess = exports.TweenTyep = void 0;
  26. var TweenTyep;
  27. (function (TweenTyep) {
  28. TweenTyep[TweenTyep["move"] = 0] = "move";
  29. TweenTyep[TweenTyep["circle"] = 1] = "circle";
  30. TweenTyep[TweenTyep["bezier"] = 2] = "bezier";
  31. TweenTyep[TweenTyep["rotate"] = 3] = "rotate";
  32. TweenTyep[TweenTyep["scale"] = 4] = "scale";
  33. })(TweenTyep = exports.TweenTyep || (exports.TweenTyep = {}));
  34. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  35. var TweenMess = /** @class */ (function () {
  36. function TweenMess() {
  37. this.tweenType = TweenTyep.move;
  38. this.posList = [cc.v2(0, 0)];
  39. this.angleV = 0;
  40. this.actTime = 1;
  41. this.delayTime = 0;
  42. }
  43. __decorate([
  44. property({ type: cc.Enum(TweenTyep) })
  45. ], TweenMess.prototype, "tweenType", void 0);
  46. __decorate([
  47. property({ type: [cc.Vec2] })
  48. ], TweenMess.prototype, "posList", void 0);
  49. __decorate([
  50. property({ visible: function () { return this.tweenType == TweenTyep.circle || this.tweenType == TweenTyep.rotate; } })
  51. ], TweenMess.prototype, "angleV", void 0);
  52. __decorate([
  53. property()
  54. ], TweenMess.prototype, "actTime", void 0);
  55. __decorate([
  56. property()
  57. ], TweenMess.prototype, "delayTime", void 0);
  58. TweenMess = __decorate([
  59. ccclass("TweenMess")
  60. ], TweenMess);
  61. return TweenMess;
  62. }());
  63. exports.TweenMess = TweenMess;
  64. var NewClass = /** @class */ (function (_super) {
  65. __extends(NewClass, _super);
  66. function NewClass() {
  67. var _this = _super !== null && _super.apply(this, arguments) || this;
  68. _this.tweenList = [];
  69. _this.startNum = 0;
  70. _this.mainTween = null;
  71. _this.angleConut = 0;
  72. _this.centerPos = cc.v2(0, 0);
  73. _this.isRotate = false;
  74. return _this;
  75. }
  76. // @property
  77. // delayTime: number = 0;
  78. NewClass.prototype.start = function () {
  79. this.creatTween();
  80. this.node.opacity = 255;
  81. };
  82. NewClass.prototype.creatTween = function () {
  83. var _this = this;
  84. this.mainTween = cc.tween(this.node);
  85. if (this.tweenList.length <= 0)
  86. return;
  87. var _loop_1 = function (i) {
  88. var tw = this_1.tweenList[i];
  89. if (tw.tweenType == TweenTyep.move) {
  90. this_1.mainTween.to(tw.actTime, { position: tw.posList[0] }).delay(tw.delayTime);
  91. }
  92. else if (tw.tweenType == TweenTyep.bezier) {
  93. this_1.runRotate();
  94. this_1.mainTween.bezierTo(tw.actTime, tw.posList[0], tw.posList[1], tw.posList[2]).delay(tw.delayTime);
  95. }
  96. else if (tw.tweenType == TweenTyep.circle) {
  97. this_1.mainTween.call(function () {
  98. _this.CurAngle = 0;
  99. _this.centerPos = tw.posList[0];
  100. // @ts-ignore
  101. var tween = cc.tween(_this).to(tw.actTime, { CurAngle: tw.angleV * tw.actTime }).start();
  102. }).delay(tw.actTime + tw.delayTime);
  103. }
  104. else if (tw.tweenType == TweenTyep.rotate) {
  105. this_1.mainTween.by(tw.actTime, { angle: tw.angleV });
  106. }
  107. else if (tw.tweenType == TweenTyep.scale) {
  108. this_1.mainTween.to(tw.actTime, { scaleX: tw.posList[0].x, scaleY: tw.posList[0].y }).delay(tw.delayTime);
  109. }
  110. };
  111. var this_1 = this;
  112. for (var i = 0; i < this.tweenList.length; i++) {
  113. _loop_1(i);
  114. }
  115. this.mainTween.union().repeatForever().start();
  116. };
  117. Object.defineProperty(NewClass.prototype, "CurAngle", {
  118. get: function () {
  119. return this.angleConut;
  120. },
  121. set: function (num) {
  122. if (Math.abs(this.angleConut - num) < 10) {
  123. var pos = cc.v2(this.node.getPosition());
  124. pos = pos.sub(this.centerPos).rotate((num - this.angleConut) / 180 * Math.PI).add(this.centerPos);
  125. this.node.setPosition(pos);
  126. }
  127. this.angleConut = num;
  128. },
  129. enumerable: false,
  130. configurable: true
  131. });
  132. NewClass.prototype.runRotate = function () {
  133. var _this = this;
  134. if (this.isRotate)
  135. return;
  136. this.isRotate = true;
  137. if (this.node.x < 0) {
  138. this.schedule(function () { _this.node.angle += 3; }, 0.01);
  139. }
  140. else {
  141. this.schedule(function () { _this.node.angle -= 3; }, 0.01);
  142. }
  143. };
  144. __decorate([
  145. property({ type: [TweenMess] })
  146. ], NewClass.prototype, "tweenList", void 0);
  147. NewClass = __decorate([
  148. ccclass
  149. ], NewClass);
  150. return NewClass;
  151. }(cc.Component));
  152. exports.default = NewClass;
  153. cc._RF.pop();