mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-25 01:24:23 +00:00
Create Collectible
behaviour based on @snowycoder's Gold
entity
This commit is contained in:
parent
9550f690dc
commit
c0055761a4
2 changed files with 29 additions and 0 deletions
15
behaviours/collectable.gd
Normal file
15
behaviours/collectable.gd
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
extends Node2D
|
||||||
|
class_name Collectable
|
||||||
|
|
||||||
|
|
||||||
|
@export var tag: StringName
|
||||||
|
|
||||||
|
|
||||||
|
signal collected(tag: StringName)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_mouse_area_mouse_entered() -> void:
|
||||||
|
collected.emit()
|
||||||
|
|
||||||
|
func _on_collected(t: StringName) -> void:
|
||||||
|
Log.p(self, "Collected: %s" % t)
|
14
behaviours/collectable.tscn
Normal file
14
behaviours/collectable.tscn
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://dj72yshd25ucx"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://behaviours/collectable.gd" id="1_p0pc3"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_su28r"]
|
||||||
|
radius = 16.4012
|
||||||
|
|
||||||
|
[node name="Collectable" type="Node2D"]
|
||||||
|
script = ExtResource("1_p0pc3")
|
||||||
|
|
||||||
|
[node name="CollectArea" type="Area2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="CollectArea"]
|
||||||
|
shape = SubResource("CircleShape2D_su28r")
|
Loading…
Reference in a new issue