奖励物品基本完成

This commit is contained in:
2024-11-26 16:26:38 +08:00
parent 3b8052761c
commit 6f58500ea9
6 changed files with 56 additions and 458 deletions

View File

@@ -1,7 +1,8 @@
import { instantiate, Prefab } from "cc";
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ItemComp } from "./ItemComp";
import { Items } from "../common/config/Items";
/** Item 模块 */
@ecs.register(`Item`)
@@ -14,6 +15,13 @@ export class Item extends ecs.Entity {
var path = "game/gui/item";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.getChildByName("num").getComponent(Label).string = num.toString();
let url = "gui/items";
let pathName= Items[uuid].path;
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
});
node.parent = praent
let iv = node.getComponent(ItemComp)!;
iv.i_uuid = uuid