BoatWave.ts 980 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import GameM, { Game_Quality } from "../manager/GameM";
  2. /** 船上下浮动 */
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class BoatWave extends cc.Component {
  6. @property(cc.Node)
  7. bowen: cc.Node = null
  8. @property(cc.Integer)
  9. startY = 0
  10. @property(cc.Integer)
  11. toY = 0
  12. private boatTween = null
  13. onEnable() {
  14. if (this.bowen) {
  15. this.bowen.active = true
  16. }
  17. if (GameM.commonData.quality <= Game_Quality.medium) {
  18. return
  19. }
  20. this.boatTween = cc.tween(this.node)
  21. .to(1, { y: this.startY })
  22. .to(1, { y: this.toY })
  23. .union()
  24. .repeatForever()
  25. .start()
  26. }
  27. onDisable() {
  28. if (this.boatTween) {
  29. this.boatTween.stop()
  30. this.boatTween = null
  31. }
  32. if (this.bowen) {
  33. this.bowen.active = false
  34. }
  35. }
  36. }