1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-25 13:02:29 +08:00

feat(物品收集): 为物品掉落添加收集动画效果

添加动画播放器组件并实现收集时的缩放淡出动画效果,提升物品收集时的视觉反馈
This commit is contained in:
2025-08-28 14:16:58 +08:00
parent e669bf1c30
commit 4b689e23fb
2 changed files with 92 additions and 2 deletions
+6 -1
View File
@@ -6,6 +6,7 @@ var stackCount: int = 1
var targetPlayer: EntityBase = null
@onready var texture: Sprite2D = $"%texture"
@onready var animator: AnimationPlayer = $"%animator"
func _ready():
apply_force(MathTool.randv2_range(30000), MathTool.randv2_range(10))
@@ -18,7 +19,7 @@ func _physics_process(_delta):
apply_central_force((targetPlayer.position - position).normalized() * 1000)
if position.distance_to(targetPlayer.position) < 60:
targetPlayer.collectItem(item, stackCount)
queue_free()
collect()
func findPlayer() -> EntityBase:
var result = null
@@ -29,6 +30,10 @@ func findPlayer() -> EntityBase:
lastDistance = position.distance_to(player.position)
result = player
return result
func collect():
animator.play("collect")
await animator.animation_finished
queue_free()
static func generate(
itemType: ItemStore.ItemType,