Files
sudoku/src/models/UIManager.ts

41 lines
927 B
TypeScript
Raw Normal View History

2025-05-12 22:06:04 +08:00
import { respath } from "../constants/respath"
2025-05-13 20:31:44 +08:00
import { StorageManager } from "./StorageManager"
2025-05-09 19:10:40 +08:00
import { Stage } from "../views/Stage"
2025-05-13 20:31:44 +08:00
2025-05-09 19:10:40 +08:00
const { regClass, property } = Laya
@regClass()
export class UIManager extends Laya.Script {
2025-05-12 22:06:04 +08:00
declare owner: Laya.Scene
2025-05-09 19:10:40 +08:00
private static _instance: UIManager
onAwake(): void {
UIManager._instance = this
2025-05-13 20:31:44 +08:00
StorageManager.getInstance().init()
2025-05-12 22:06:04 +08:00
this.loadHome()
2025-05-09 19:10:40 +08:00
}
public static getInstance(): UIManager {
return UIManager._instance
}
2025-05-12 22:06:04 +08:00
public loadHome(): void {
Laya.loader.load(respath.home_ui_res).then((go)=>{
var prefab = go.create()
this.owner.addChild(prefab)
})
}
2025-05-09 19:10:40 +08:00
public loadStage(): void {
2025-05-12 22:06:04 +08:00
Laya.loader.load(respath.stage_ui_res).then((go)=>{
var prefab = go.create()
var stage = this.owner.addChild(prefab).getComponent(Stage)
2025-05-13 20:31:44 +08:00
stage.onLoadStage(StorageManager.getInstance().loadStage("first"))
2025-05-12 22:06:04 +08:00
})
2025-05-09 19:10:40 +08:00
}
}