mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-28 22:42:31 +08:00
feat(ItemShow): 为物品展示添加自动释放功能
在ItemShow.generate方法中新增isAutoFree参数,控制物品展示节点是否自动释放。这解决了需要手动管理物品展示节点内存的问题。
This commit is contained in:
@@ -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]
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user