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; @property(Node) carrot:Node=null; start() { let btnLogin = this.node.getChildByName("Button") btnLogin.on(Button.EventType.CLICK,this.onBtnLogin,this) this.carrot.setScale(0.5,0.5); this.birdAnimation(); this.carrotAnimation(); } carrotAnimation(){ tween(this.carrot) .to(0.5,{scale : new Vec3(1,1)}) .start() } 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) } }