1、创建项目并资源导入
2、制作打地鼠界面UI (Game.UI)
3、加载资源并显示打地鼠界面。(Main.ts主程序)
Main.ts 主程序(游戏入口)
图集打包:
var resArray: Array<any> = [
{ url: "res/atlas/gamestart/gamestart.json", type: Laya.Loader.ATLAS },
{ url: "res/atlas/gameview/gameview.json", type: Laya.Loader.ATLAS },
{ url: "res/atlas/gameover/gameover.json", type: Laya.Loader.ATLAS },
{ url: "res/atlas/hammer/hammer.json", type: Laya.Loader.ATLAS }, ];
4、地鼠的显示、停留、消失、受击、重置。
Mole.ts(地鼠类)
//重置
reset(): void {
this.normalState.visible = false;
this.hitState.visible = false;
this.scoreimg.visible = false;
this.isActive = false;
this.isShow = false;
this.isHit = false;
}
//显示
show():void{
if(this.isActive)return;
//判断小鼠是否处于运动,运动就直接返回
//缓动函数 (