MouseDecor.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import { MouseConst } from "./MouseConst";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export default class MouseDecor extends cc.Component {
  11. @property(cc.Node)
  12. flowerLeft: cc.Node = null;
  13. @property(cc.Node)
  14. flowerRight: cc.Node = null;
  15. @property(cc.Node)
  16. grassLeft: cc.Node = null;
  17. @property(cc.Node)
  18. grassRight: cc.Node = null;
  19. @property(cc.Node)
  20. goldLeft: cc.Node = null;
  21. @property(cc.Node)
  22. goldRight: cc.Node = null;
  23. @property(cc.Node)
  24. rodarate: cc.Node = null;
  25. onEnterSuper() {
  26. cc.tween(this.flowerLeft)
  27. .to(MouseConst.SUPER_ENTER_TIME, { x: this.flowerLeft.x - this.flowerLeft.width })
  28. .start();
  29. cc.tween(this.flowerRight)
  30. .to(MouseConst.SUPER_ENTER_TIME, { x: this.flowerRight.x + this.flowerRight.width })
  31. .start();
  32. cc.tween(this.grassLeft)
  33. .to(MouseConst.SUPER_ENTER_TIME, { x: this.grassLeft.x + 100, y: this.grassLeft.y - 60 })
  34. .start();
  35. cc.tween(this.grassRight)
  36. .to(MouseConst.SUPER_ENTER_TIME, { x: this.grassRight.x - 100, y: this.grassRight.y - 60 })
  37. .start();
  38. cc.tween(this.goldLeft)
  39. .to(MouseConst.SUPER_ENTER_TIME, { x: this.goldLeft.x + 150, y: this.goldLeft.y + 100 })
  40. .start();
  41. cc.tween(this.goldRight)
  42. .to(MouseConst.SUPER_ENTER_TIME, { x: this.goldRight.x - 150, y: this.goldRight.y + 100 })
  43. .call(() => {
  44. cc.tween(this.rodarate)
  45. .delay(1)
  46. .set({ scale: 0, opacity: 255, active: true })
  47. .to(0.2, { scale: 1.2 })
  48. .to(0.1, { scale: 1 })
  49. .start();
  50. })
  51. .start();
  52. }
  53. onExitSuper() {
  54. cc.tween(this.flowerLeft)
  55. .to(MouseConst.SUPER_EXIT_TIME, { x: this.flowerLeft.x + this.flowerLeft.width })
  56. .start();
  57. cc.tween(this.flowerRight)
  58. .to(MouseConst.SUPER_EXIT_TIME, { x: this.flowerRight.x - this.flowerRight.width })
  59. .start();
  60. cc.tween(this.grassLeft)
  61. .to(MouseConst.SUPER_EXIT_TIME, { x: this.grassLeft.x - 100, y: this.grassLeft.y + 60 })
  62. .start();
  63. cc.tween(this.grassRight)
  64. .to(MouseConst.SUPER_EXIT_TIME, { x: this.grassRight.x + 100, y: this.grassRight.y + 60 })
  65. .start();
  66. cc.tween(this.goldLeft)
  67. .to(MouseConst.SUPER_EXIT_TIME, { x: this.goldLeft.x - 150, y: this.goldLeft.y - 100 })
  68. .start();
  69. cc.tween(this.goldRight)
  70. .to(MouseConst.SUPER_EXIT_TIME, { x: this.goldRight.x + 150, y: this.goldRight.y - 100 })
  71. .start();
  72. cc.tween(this.rodarate)
  73. .delay(0.3)
  74. .to(0.3, { opacity: 0 })
  75. .set({ active: false })
  76. .start();
  77. }
  78. }