LabelTip.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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, executeInEditMode: r } = cc._decorator;
  18. e = class extends cc.Component {
  19. constructor() {
  20. super(...arguments), (this.label = null), (this.paddingX = 0);
  21. }
  22. leftToRight(t = !0, e = 1) {
  23. return (
  24. (this.isAutoDestroy = t),
  25. (this.node.opacity = 0),
  26. (this.node.x = -cc.winSize.width / 2),
  27. (this.node.y = 0),
  28. cc
  29. .tween(this.node)
  30. .to(0.3, { x: -50, opacity: 255 }, { easing: "sineInOut" })
  31. .to(e, { x: 50 })
  32. .to(0.3, { x: cc.winSize.width / 2 }, { easing: "sineIn" })
  33. .call(this.showFinish.bind(this))
  34. .start()
  35. );
  36. }
  37. init(t, e, i = 40, s) {
  38. return (
  39. t.addChild(this.node),
  40. (this.label.fontSize = i),
  41. (this.label.lineHeight = i),
  42. (this.label.string = e),
  43. s && (this.node.color = s),
  44. this
  45. );
  46. }
  47. showTipSmallToBig(t = !0) {
  48. (this.isAutoDestroy = t),
  49. (this.node.opacity = 0),
  50. (this.node.x = 0),
  51. (this.node.y = 0),
  52. (this.node.scale = 0),
  53. (this.tween = cc
  54. .tween(this.node)
  55. .to(0.2, { scale: 1, opacity: 255 })
  56. .delay(0.8)
  57. .to(0.5, { opacity: 0 })
  58. .call(this.showFinish.bind(this))
  59. .start());
  60. }
  61. flyUp(t, e, i = !0) {
  62. (this.isAutoDestroy = i),
  63. (this.node.y = e),
  64. (this.node.x = t),
  65. (this.node.opacity = 255),
  66. cc
  67. .tween(this.node)
  68. .to(0.1, { scale: 1.1 }, { easing: cc.easing.sineOut })
  69. .to(0.1, { scale: 1 }, { easing: cc.easing.sineIn })
  70. .to(0.7, { y: e + 50 })
  71. .delay(0.2)
  72. .to(0.3, { opacity: 0 })
  73. .call(this.showFinish.bind(this))
  74. .start();
  75. }
  76. showFinish() {
  77. (this.tween = null), this.isAutoDestroy && this.destroyLab();
  78. }
  79. destroyLab() {
  80. this.node.pool ?
  81. (this.node.pool.push(this.node), (this.node.pool = null)) :
  82. (this.node.removeFromParent(), this.node.destroy());
  83. }
  84. };
  85. s([a(cc.Label)], e.prototype, "label", void 0),
  86. s([a()], e.prototype, "paddingX", void 0),
  87. (e = s([o, r], e)),
  88. (i.default = e);