资源预加载

This commit is contained in:
2025-05-29 17:48:51 +08:00
parent aefc0be816
commit 445d19af79

View File

@@ -1,4 +1,5 @@
import { config } from "./constants/config"
import { respath } from "./constants/respath"
import { LevelManager } from "./models/LevelManager"
import { StorageManager } from "./models/StorageManager"
@@ -14,6 +15,24 @@ export class Main extends Laya.Script {
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 {