1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-28 06:22:40 +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( itemCollected.connect(
func(itemType, amount): func(itemType, amount):
UIState.itemCollect.add_child(ItemShow.generate(itemType, amount)) UIState.itemCollect.add_child(ItemShow.generate(itemType, amount, true))
) )
else: else:
currentFocusedBoss = get_tree().get_nodes_in_group("players")[0] 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) avatarTexture.texture = ItemStore.getTexture(type)
countLabel.text = str(count) 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() var item = preload("res://components/UI/ItemShow.tscn").instantiate()
item.type = itemType item.type = itemType
item.count = itemCount item.count = itemCount
item.autoFree = isAutoFree
return item return item