Arreglados los pickups

This commit is contained in:
Diego De la Viuda Llorente committed 2026-10-20 18:01:21 +02:00
1 parent 5c3d16951e
commit 1fbfdf3f8a
9 files changed
+41 -38

No files matched your search

+7 -3
View File
@@ -15,12 +15,16 @@ var grounded: bool = false
@onready var label: Label = $Label
@onready var sprite: Sprite2D = $Sprite2D
@onready var placeholder: ColorRect = $Sprite2D/ColorRect
func _ready() -> void:
add_to_group("pickup")
if pickup_data != null:
label.text = pickup_data.display_name
sprite.texture = pickup_data.icon
placeholder.visible = pickup_data.icon == null
placeholder.color = pickup_data.color
start_y = position.y
body_entered.connect(_on_body_entered)
@@ -47,7 +51,7 @@ func is_on_floor() -> bool:
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("player"):
if pickup_data != null:
if body.is_in_group("player") and body.has_method("collect_pickup"):
if body.collect_pickup(pickup_data):
picked_up.emit(self, pickup_data)
queue_free()
queue_free()