整理代码格式
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { respath } from "../constants/respath"
|
||||
|
||||
|
||||
|
||||
export class ResourceManager {
|
||||
private static instance: ResourceManager
|
||||
public static getInstance(): ResourceManager {
|
||||
@@ -14,9 +12,7 @@ export class ResourceManager {
|
||||
private resources: Array<{ url: string, type?: any, lazy?: boolean }> = []
|
||||
private reqs: Map<string, Array<Laya.Image>> = new Map()
|
||||
|
||||
|
||||
public init(): void {
|
||||
|
||||
this.resources.push({ url: respath.score_add_ui_res() })
|
||||
this.resources.push({ url: respath.dc_ui_res() })
|
||||
this.resources.push({ url: respath.trophy_ui_res() })
|
||||
@@ -43,7 +39,7 @@ export class ResourceManager {
|
||||
|
||||
Laya.loader.load(this.resources, Laya.Handler.create(this, (obj: object) => { // 第二个参数:成功回调
|
||||
console.log("预加载资源结束>>>>", obj)
|
||||
this.reqs.forEach((list: Array<Laya.Image>, path: string)=>{
|
||||
this.reqs.forEach((list: Array<Laya.Image>, path: string) => {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const img = list[i]
|
||||
if (img && img.parent) {
|
||||
@@ -53,9 +49,8 @@ export class ResourceManager {
|
||||
})
|
||||
this.reqs.clear()
|
||||
}), Laya.Handler.create(this, (resProg: number) => { // 第三个参数:进度回调
|
||||
// console.log("预加载资源进度>>>>", resProg)
|
||||
console.log("预加载资源进度>>>>", resProg)
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
public loadTexture(path: string, image: Laya.Image): void {
|
||||
@@ -66,9 +61,9 @@ export class ResourceManager {
|
||||
image.texture = obj
|
||||
} else {
|
||||
if (!this.reqs.has(path)) {
|
||||
this.reqs.set(path, new Array())
|
||||
this.reqs.set(path, [])
|
||||
}
|
||||
let list = this.reqs.get(path)
|
||||
const list = this.reqs.get(path)
|
||||
list.push(image)
|
||||
|
||||
let find = false
|
||||
@@ -91,11 +86,8 @@ export class ResourceManager {
|
||||
}
|
||||
}
|
||||
this.reqs.delete(path)
|
||||
}), Laya.Handler.create(this, (resProg: number) => { // 第三个参数:进度回调
|
||||
// console.log("加载资源进度>>>>", path, resProg)
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user