Files
sudoku/src/Main.ts
2025-05-29 19:15:32 +08:00

39 lines
1.4 KiB
TypeScript

import { config } from "./constants/config"
import { respath } from "./constants/respath"
import { LevelManager } from "./models/LevelManager"
import { StorageManager } from "./models/StorageManager"
const { regClass, property } = Laya
@regClass()
export class Main extends Laya.Script {
@property(Boolean)
public debug: boolean = false
onAwake() {
console.log("Game onAwake")
config.DEBUG = this.debug
LevelManager.getInstance().init()
StorageManager.getInstance().init()
const resources: Array<{ url: string, type?: any, lazy?: boolean }> = [
{ url: respath.home_top_dc_bg_normal, type: Laya.Loader.IMAGE },
{ url: respath.home_top_dc_bg_finish, type: Laya.Loader.IMAGE },
{ url: respath.dc_top_bg_normal, type: Laya.Loader.IMAGE },
{ url: respath.dc_top_bg_month_finish, type: Laya.Loader.IMAGE },
{ url: respath.trophy_bg_light_gold, type: Laya.Loader.IMAGE },
{ url: respath.trophy_bg_light_grey, type: Laya.Loader.IMAGE }
]
Laya.loader.load(resources, Laya.Handler.create(this, (success: object) => { // 第二个参数:成功回调
console.log("预加载资源结束>>>>", success)
}), Laya.Handler.create(this, (resProg: number) => { // 第三个参数:进度回调
console.log("预加载资源进度>>>>", resProg)
}))
}
onLateUpdate(): void {
StorageManager.getInstance().saveUser()
StorageManager.getInstance().saveStage()
}
}