1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Statemachine/ItemShow.gd
T
fallingshrimp 4c5842fb9e refactor(资源加载): 将preload替换为load以优化内存使用
统一使用load方法动态加载资源,减少启动时的内存占用
移动Manager类到Tools/Managers目录下
修复DirTool处理remap文件的问题
2025-09-21 12:53:15 +08:00

31 lines
947 B
GDScript

@tool
extends HBoxContainer
class_name ItemShow
@export var type: ItemStore.ItemType = ItemStore.ItemType.BASEBALL
@export var count: int = 0
@export var autoFree: bool = false
@onready var avatarTexture: TextureRect = $"%avatar"
@onready var countLabel: Label = $"%count"
@onready var animator: AnimationPlayer = $"%animator"
func _ready():
if autoFree:
animator.play("show")
await animator.animation_finished
await TickTool.millseconds(GameRule.itemShowLifetime) # 等待几秒后自动隐藏
animator.play("hide")
await animator.animation_finished
queue_free()
func _physics_process(_delta):
avatarTexture.texture = ItemStore.getTexture(type)
countLabel.text = str(count)
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false):
var item = load("res://components/UI/ItemShow.tscn").instantiate()
item.type = itemType
item.count = itemCount
item.autoFree = isAutoFree
return item