import { _decorator, Button, Component, Node,director ,tween, Vec3} from 'cc'; const { ccclass, property } = _decorator; @ccclass('NewComponent') export class NewComponent extends Component { @property(Node) bird:Node=null; start() { let btnLogin = this.node.getChildByName("Button") btnLogin.on(Button.EventType.CLICK,this.onBtnLogin,this) this.birdAnimation(); } birdAnimation(){ let x = this.bird.getPosition().x; let y = this.bird.getPosition().y; tween(this.bird) .repeatForever( tween() .to(1,{position : new Vec3(x,y - 10)},{easing : 'sineInOut'}) .to(1,{position : new Vec3(x,y + 10)},{easing : 'sineInOut'}) ) .start(); } onBtnLogin(){ director.loadScene("SelectScene"); } update(deltaTime: number) { let x = this.bird.getPosition().x; let y = this.bird.getPosition().y; this.bird.setPosition(x,y) } }