资源预加载
This commit is contained in:
19
src/Main.ts
19
src/Main.ts
@@ -1,4 +1,5 @@
|
|||||||
import { config } from "./constants/config"
|
import { config } from "./constants/config"
|
||||||
|
import { respath } from "./constants/respath"
|
||||||
import { LevelManager } from "./models/LevelManager"
|
import { LevelManager } from "./models/LevelManager"
|
||||||
import { StorageManager } from "./models/StorageManager"
|
import { StorageManager } from "./models/StorageManager"
|
||||||
|
|
||||||
@@ -14,6 +15,24 @@ export class Main extends Laya.Script {
|
|||||||
config.DEBUG = this.debug
|
config.DEBUG = this.debug
|
||||||
LevelManager.getInstance().init()
|
LevelManager.getInstance().init()
|
||||||
StorageManager.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 {
|
onLateUpdate(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user