1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

feat(ItemShow): 为物品展示添加自动释放功能

在ItemShow.generate方法中新增isAutoFree参数,控制物品展示节点是否自动释放。这解决了需要手动管理物品展示节点内存的问题。
This commit is contained in:
2025-08-28 06:55:18 +08:00
parent ac809194e7
commit 71a77dbdca
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ func _ready():
)
itemCollected.connect(
func(itemType, amount):
UIState.itemCollect.add_child(ItemShow.generate(itemType, amount))
UIState.itemCollect.add_child(ItemShow.generate(itemType, amount, true))
)
else:
currentFocusedBoss = get_tree().get_nodes_in_group("players")[0]
+2 -1
View File
@@ -19,8 +19,9 @@ func _physics_process(_delta):
avatarTexture.texture = ItemStore.getTexture(type)
countLabel.text = str(count)
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1):
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false):
var item = preload("res://components/UI/ItemShow.tscn").instantiate()
item.type = itemType
item.count = itemCount
item.autoFree = isAutoFree
return item