奖励物品基本完成
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user