const {ccclass, property} = cc._decorator;

@ccclass
export default class Camera extends cc.Component {
    canUpY:number = (1600-cc.winSize.height)/2;
    canDownY:number = -(1600-cc.winSize.height)/2;

    update(dt:number){
        if(!window.gm.isGameOver){
            if(window.boy&&window.boy.isValid){
                let nextY = window.boy.node.y;
                if(nextY>this.canDownY&&nextY<this.canUpY){
                    this.node.y = nextY;
                }else{
                    if(nextY<0){
                       this.node.y = this.canDownY;
                    }else if(nextY>0){
                        this.node.y = this.canUpY;
                    }
                }
            }
        }
    }
}
