import { RandomInt } from "../script/util";

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
  @property
  rotate: number = 10;

  basePos: cc.Vec2;

  start() {
    this.basePos = this.node.getPosition();
    this.float();
  }

  float() {
    const rotation = RandomInt(this.rotate, -this.rotate);
    cc.tween(this.node)
      .to(RandomInt(2, 4), {
        angle: rotation,
      }, { easing: 'sineInOut' })
      .to(RandomInt(2, 4), {
        angle: -rotation,
      }, { easing: 'sineInOut' })
      .call(() => {
        this.float();
      })
      .start();
  }
}
