ViewAni.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s,
  5. e =
  6. (this && this.__decorate) ||
  7. function(t, e, i, s) {
  8. var o,
  9. a = arguments.length,
  10. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  11. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  12. else
  13. for (var r = t.length - 1; 0 <= r; r--)
  14. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  15. return 3 < a && n && Object.defineProperty(e, i, n), n;
  16. };
  17. Object.defineProperty(i, "__esModule", { value: !0 });
  18. const o = t("App"),
  19. { ccclass: a, property: n, menu: r, executeInEditMode: l, executionOrder: h } = cc._decorator;
  20. let c = {
  21. TopToBottom: {
  22. run: function(t, e) {
  23. let i = cc.tween(t).to(0.6, { y: 0 }, { easing: cc.easing.bounceOut });
  24. e && i.call(e), (t.y = cc.winSize.height), i.start();
  25. },
  26. fast: function(t, e) {
  27. e && e(), (t.y = 0);
  28. }
  29. },
  30. test: {
  31. run: function(t, e) {
  32. (t.y = cc.winSize.height / 2 - 230), (t.x = cc.winSize.width / 2 - 15), (t.scale = 0);
  33. let i = cc
  34. .tween(t)
  35. .parallel(
  36. cc.tween().bezierTo(0.3, t.position, cc.v2(t.x / 2, t.y + 100), cc.Vec2.ZERO),
  37. cc.tween().to(0.3, { scale: 1 }, cc.easeExponentialIn())
  38. );
  39. e && i.call(e), i.start();
  40. },
  41. fast: function(t, e) {
  42. e && e(), (t.y = 0);
  43. }
  44. },
  45. BottomToTop: {
  46. run: function(t, e) {
  47. let i = cc.tween(t).to(0.5, { y: cc.winSize.height }, { easing: cc.easing.cubicOut });
  48. e && i.call(e), i.start();
  49. },
  50. fast: function(t, e) {
  51. e && e(), (t.y = 0);
  52. }
  53. },
  54. Enter_BottomToTop: {
  55. run: function(t, e) {
  56. t.y -= cc.winSize.height;
  57. let i = cc.tween(t).to(0.3, { y: 0 }, { easing: cc.easing.backOut });
  58. e && i.call(e), i.start();
  59. },
  60. fast: function(t, e) {
  61. e && e(), (t.y = 0);
  62. }
  63. },
  64. Exit_CenterToBottom: {
  65. run: function(t, e) {
  66. let i = cc.tween(t).to(0.3, { y: -cc.winSize.height }, { easing: cc.easing.backOut });
  67. e && i.call(e), i.start();
  68. },
  69. fast: function(t, e) {
  70. e && e(), (t.y = 0);
  71. }
  72. }
  73. },
  74. d = (s = class extends cc.Component {
  75. constructor() {
  76. super(...arguments),
  77. (this._enterAniAsset = null),
  78. (this._exitAniAsset = null),
  79. (this._enterTweenName = ""),
  80. (this._exitTweenName = ""),
  81. (this._ani = null),
  82. (this.isExiting = !1),
  83. (this._exitAni = 0),
  84. (this._enterAni = 0),
  85. (this.view = null),
  86. (this._isFirst = !0),
  87. (this._curScale = 1);
  88. }
  89. get exitAni() {
  90. return this._exitAni;
  91. }
  92. set exitAni(t) {
  93. this._exitAni !== t &&
  94. ((this._exitAni = t), (this._exitAniAsset = null), (this._exitTweenName = ""), t) &&
  95. ("string" == typeof(t = s.viewAnis[t]) ? (this._exitTweenName = t) : (this._exitAniAsset = t));
  96. }
  97. isExitAni() {
  98. return (this._exitAniAsset || this._exitTweenName) && s.isCanPlayAni;
  99. }
  100. get enterAni() {
  101. return this._enterAni;
  102. }
  103. set enterAni(t) {
  104. this._enterAni !== t &&
  105. ((this._enterAni = t), (this._enterAniAsset = null), (this._enterTweenName = ""), t) &&
  106. ("string" == typeof(t = s.viewAnis[t]) ? (this._enterTweenName = t) : (this._enterAniAsset = t));
  107. }
  108. start() {}
  109. onEnterAnimCompleted() {
  110. this.view.enterAniFinish();
  111. }
  112. onAnimCompleted() {
  113. this.isExiting &&
  114. ((this.isExiting = !1),
  115. this.node.parent && this.node.parent.removeChild(this.node, !1),
  116. (this.node.active = !1),
  117. (this.node.scale = this._curScale),
  118. o.default.ViewManager.checkIsNeedAddBg(),
  119. this.view.onExitAniFinish());
  120. }
  121. onEnter() {
  122. if (this.enabled)
  123. if (this._isFirst && s.isCanPlayAni) {
  124. let e = this.node.opacity;
  125. (this.node.opacity = 0),
  126. o.default.TimerManager.setFrameOut(
  127. 2,
  128. () => {
  129. (this.node.opacity = e), this.playEnterAni();
  130. let t = this.getComponent(cc.Widget);
  131. t && (t.enabled = !1);
  132. },
  133. this
  134. ),
  135. (this._isFirst = !1);
  136. } else this.playEnterAni();
  137. this.isExiting = !1;
  138. }
  139. playEnterAni() {
  140. this._enterAniAsset ?
  141. (s.isCanPlayAni ?
  142. this._ani.play(this._enterAniAsset.name) :
  143. this._ani.play(this._enterAniAsset.name, this._enterAniAsset.duration),
  144. this._ani.once(cc.Animation.EventType.FINISHED, this.onEnterAnimCompleted, this)) :
  145. this._enterTweenName &&
  146. c[this._enterTweenName] &&
  147. (s.isCanPlayAni ?
  148. c[this._enterTweenName].run(this.node, this.onEnterAnimCompleted.bind(this)) :
  149. (c[this._enterTweenName].fast(this.node), this.onEnterAnimCompleted()));
  150. }
  151. onExit() {
  152. s.isCanPlayAni &&
  153. ((this.isExiting = !0),
  154. this.enabled &&
  155. ((this._curScale = this.node.scale),
  156. this._exitAniAsset ?
  157. (this._ani.once(cc.Animation.EventType.FINISHED, this.onAnimCompleted, this),
  158. this._ani.play(this._exitAniAsset.name)) :
  159. this._exitTweenName &&
  160. c[this._exitTweenName] &&
  161. c[this._exitTweenName].run(this.node, this.onAnimCompleted.bind(this))));
  162. }
  163. onLoad() {
  164. (this._enterAniAsset || this._exitAniAsset) &&
  165. ((this._ani = this.addComponent(cc.Animation)),
  166. this._enterAniAsset && this._ani.addClip(this._enterAniAsset),
  167. this._exitAniAsset && this._ani.addClip(this._exitAniAsset));
  168. }
  169. });
  170. (d.isCanPlayAni = !0),
  171. (d.viewAnis = null),
  172. e([n(cc.AnimationClip)], d.prototype, "_enterAniAsset", void 0),
  173. e([n(cc.AnimationClip)], d.prototype, "_exitAniAsset", void 0),
  174. e([n()], d.prototype, "_enterTweenName", void 0),
  175. e([n()], d.prototype, "_exitTweenName", void 0),
  176. e([n({ editorOnly: !0 })], d.prototype, "_exitAni", void 0),
  177. e([n({ type: cc.Enum({}) })], d.prototype, "exitAni", null),
  178. e([n({ editorOnly: !0 })], d.prototype, "_enterAni", void 0),
  179. e([n({ type: cc.Enum({}) })], d.prototype, "enterAni", null),
  180. (s = e([a, l, h(-1)], d)),
  181. (i.default = s);