第七节 游戏结算界面制作与游戏屏幕适配
- 制作游戏结束界面
屏幕适配
制作游戏结束界面
导入素材
新建页面
将背景加入页面
因为拉伸了 所以图片很模糊
双击图片
点击确定 锁住图片
把其他素材拖进去
把默认的label删掉
把Game的分数栏复制过来
保存 导出
在src下创建GameOver.js
GameOver.js
var GameOver=(function(_super){
function GameOver(){
GameOver.super(this);
this.restartBtn.on(Laya.Event.CLICK,this,this.restartGame);
}
Laya.class(GameOver,"GameOver",_super);
var _proto=GameOver.prototype;
_proto.restartGame=function(){
this.removeSelf();
LayaUISample.game.removeSelf();
Laya.stage.addChild(LayaUISample.gameStart);
}
//设置分数的显示
_proto.setScoreUI=function(score){
this.data={};
this.temp=score;
for(var i=9;i>=0;i--){
this.data["item"+i]={index:Math.floor(this.temp%10)};
this.temp/=10;
}
this.scoreNums.dataSource=this.data;
}
return GameOver;
})(ui.GameOverUI);
Game.js
var