Breath.ts 534 B

12345678910111213141516171819202122
  1. import { _decorator, Component, Node, tween, Tween, v3 } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('Misc/Breath')
  4. export class Breath extends Component {
  5. private tw: Tween<Node> = null
  6. protected onEnable(): void {
  7. this.tw = tween(this.node)
  8. this.tw.to(0.75, { scale: v3(1.1, 1.1, 1) }).to(0.75, { scale: v3(1, 1, 1) }).union().repeatForever().start()
  9. }
  10. protected onDisable(): void {
  11. this.node.scale = v3(1, 1, 1)
  12. this.tw.stop()
  13. this.tw = null
  14. }
  15. }