const {ccclass, property} = cc._decorator; /**登录界面 */ @ccclass export default class Login extends cc.Component { public btn_start:cc.Node; public btn_teach:cc.Node; public progressBar:cc.Sprite; public onLoad():void{ this.btn_start = this.node.getChildByName('start'); this.btn_teach = this.node.getChildByName('teach'); this.progressBar = this.node.getChildByName('progress').getChildByName('bar').getComponent(cc.Sprite); this.btn_start.on(cc.Node.EventType.TOUCH_END,this.startGame,this); this.btn_teach.on(cc.Node.EventType.TOUCH_END,this.startGame.bind(this,true),this,); this.adapteDevice(); this.fadeInAnimation(); cc.audioEngine.playMusic(window.gameMgr.ad_bgm,true); } /**入场动画 */ private fadeInAnimation():void{ this.btn_start.x = window.gameMgr.gameViewSize.width; this.btn_start.runAction(cc.sequence( cc.delayTime(0.5), cc.moveTo(0.5,cc.v2(0,this.btn_start.y)).easing(cc.easeBackOut()), cc.shake(0.5,20,20), )); this.scheduleOnce(()=>{ cc.audioEngine.playEffect(window.gameMgr.ad_bong,false); },0.8); } /**适配设备 */ public adapteDevice():void{ let winWidth = cc.winSize.width; let winHeight = cc.winSize.height; let desWidth = cc.view.getDesignResolutionSize().width; let desHeight = cc.view.getDesignResolutionSize().height; //fixHeight前提下的适配方案 if(winWidth/winHeight>desWidth/desHeight+0.1){ //如果设备过宽,背景宽度不变(针对ipad) window.gameMgr.gameViewSize = cc.size(desWidth,desHeight);//记录游戏可视区域大小 }else if(winWidth/winHeight{ this.progressBar.fillRange = completeCount/totalCount; },()=>{ this.node.removeAllChildren(true); let isOldPlayer = cc.sys.localStorage.getItem('isOldPlayer'); if(isOldPlayer=='true'&&teach!=true){ window.gameMgr.startGame(); }else{ window.gameMgr.startTeachMode(); } }); } }