mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-24 17:14:23 +00:00
Make Collectable
an Area2D
This commit is contained in:
parent
c12df50328
commit
85d487a56c
2 changed files with 10 additions and 12 deletions
|
@ -1,15 +1,17 @@
|
|||
extends Node2D
|
||||
extends Area2D
|
||||
class_name Collectable
|
||||
|
||||
## Emits [signal collected] when the mouse enters the given [CollisionShape2D].
|
||||
|
||||
|
||||
signal collected
|
||||
|
||||
|
||||
@export var tag: StringName
|
||||
@export var qty: int = 1
|
||||
@export var tag: StringName = &""
|
||||
|
||||
|
||||
func _on_mouse_area_mouse_entered() -> void:
|
||||
func _on_mouse_entered() -> void:
|
||||
collected.emit(tag)
|
||||
|
||||
func _on_collected(t: StringName) -> void:
|
||||
Log.p(self, "Collected: %s" % t)
|
||||
func _on_collected() -> void:
|
||||
Log.p(self, "Collected: %sx %s" % [qty, tag])
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
|
||||
[ext_resource type="Script" path="res://behaviours/collectable.gd" id="1_p0pc3"]
|
||||
|
||||
[node name="Collectable" type="Node2D"]
|
||||
[node name="Collectable" type="Area2D"]
|
||||
script = ExtResource("1_p0pc3")
|
||||
|
||||
[node name="MouseArea" type="Area2D" parent="."]
|
||||
collision_mask = 0
|
||||
monitorable = false
|
||||
|
||||
[connection signal="collected" from="." to="." method="_on_collected"]
|
||||
[connection signal="mouse_entered" from="MouseArea" to="." method="_on_mouse_area_mouse_entered"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
|
|
Loading…
Reference in a new issue