LoginScene.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { _decorator, Button, Component, Node,director ,tween, Vec3} from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('NewComponent')
  4. export class NewComponent extends Component {
  5. @property(Node)
  6. bird:Node=null;
  7. start() {
  8. let btnLogin = this.node.getChildByName("Button")
  9. btnLogin.on(Button.EventType.CLICK,this.onBtnLogin,this)
  10. this.birdAnimation();
  11. }
  12. birdAnimation(){
  13. let x = this.bird.getPosition().x;
  14. let y = this.bird.getPosition().y;
  15. tween(this.bird)
  16. .repeatForever(
  17. tween()
  18. .to(1,{position : new Vec3(x,y - 10)},{easing : 'sineInOut'})
  19. .to(1,{position : new Vec3(x,y + 10)},{easing : 'sineInOut'})
  20. )
  21. .start();
  22. }
  23. onBtnLogin(){
  24. director.loadScene("SelectScene");
  25. }
  26. update(deltaTime: number) {
  27. let x = this.bird.getPosition().x;
  28. let y = this.bird.getPosition().y;
  29. this.bird.setPosition(x,y)
  30. }
  31. }