This commit is contained in:
walkpan
2025-02-01 00:14:25 +08:00
parent c5c01c6cf4
commit bffbb9077e
91 changed files with 2067 additions and 1327 deletions

View File

@@ -0,0 +1,37 @@
import { Prefab, resources } from 'cc';
import { GameConstants } from '../common/Constants';
export class SpineManager {
private _cache: Map<string, Prefab> = new Map();
async load(spinePath: string): Promise<Prefab> {
if (this._cache.has(spinePath)) {
return this._cache.get(spinePath)!;
}
const prefab = await this._load(spinePath);
this._cache.set(spinePath, prefab);
return prefab;
}
private _load(path: string): Promise<Prefab> {
return new Promise((resolve, reject) => {
resources.load(path, Prefab, (err, prefab) => {
err ? reject(err) : resolve(prefab);
});
});
}
release(spinePath: string) {
if (this._cache.has(spinePath)) {
resources.release(spinePath);
this._cache.delete(spinePath);
}
}
// 加载英雄资源
async loadHero(name: string): Promise<Prefab> {
const path = `${GameConstants.SPINE.HERO}/${name}`;
return this.load(path);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "10e51fd3-8d01-4030-80a3-f98466d8c017",
"files": [],
"subMetas": {},
"userData": {}
}