Floaty.ts 583 B

1234567891011121314151617181920212223
  1. import { _decorator, Component, Node, tween, v3 } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('Misc/Floaty')
  4. export class Floaty extends Component {
  5. @property
  6. private floatInterval: number = 0.5
  7. @property
  8. private floatOffset: number = 10
  9. start() {
  10. const tw = tween(this.node)
  11. tw.sequence(
  12. tween(this.node).by(this.floatInterval, { position: v3(0, this.floatOffset, 0) }),
  13. tween(this.node).by(this.floatInterval, { position: v3(0, -this.floatOffset, 0) }),
  14. ).repeatForever().start()
  15. }
  16. }