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,18 @@
import { _decorator, Component, Node, instantiate, Prefab, resources } from 'cc';
export class HeroManager {
static async createHero(parent: Node) {
const prefab = await this.loadPrefab('prefabs/Hero');
const hero = instantiate(prefab);
parent.addChild(hero);
return hero;
}
private static loadPrefab(path: string): Promise<Prefab> {
return new Promise((resolve, reject) => {
resources.load(path, Prefab, (err, prefab) => {
err ? reject(err) : resolve(prefab!);
});
});
}
}