34 lines
900 B
TypeScript
34 lines
900 B
TypeScript
|
|
import { UIManager } from "../models/UIManager";
|
|
import { StorageManager } from "../models/StorageManager";
|
|
|
|
const { regClass, property } = Laya
|
|
|
|
@regClass()
|
|
export class Home extends Laya.Script {
|
|
declare owner : Laya.Box;
|
|
|
|
@property(Laya.Button)
|
|
public btn_start: Laya.Button;
|
|
|
|
@property(Laya.Button)
|
|
public btn_clean: Laya.Button;
|
|
|
|
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
|
onAwake(): void {
|
|
this.btn_start.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
|
console.log("btn_start=", evt);
|
|
UIManager.getInstance().loadStage("first");
|
|
this.owner.destroy()
|
|
})
|
|
|
|
this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
|
console.log("btn_clean=", evt);
|
|
StorageManager.getInstance().cleanStage()
|
|
Laya.LocalStorage.clear()
|
|
})
|
|
}
|
|
|
|
|
|
}
|