1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-21 23:34:18 +00:00

trying to test collector and collectible

This commit is contained in:
Matteo Balugani 2023-10-01 11:56:54 +02:00 committed by Stefano Pigozzi
parent bd3a764a80
commit abc6b06654
Signed by: steffo
GPG key ID: 2A24051445686895
3 changed files with 14 additions and 2 deletions

View file

@ -1,6 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://bk1vvq5rug01m"]
[gd_scene load_steps=3 format=3 uid="uid://bk1vvq5rug01m"]
[ext_resource type="Script" path="res://collector/collectible.gd" id="1_qilbk"]
[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="2_2nvfu"]
[node name="Collectible" type="Node"]
script = ExtResource("1_qilbk")
[node name="Valuable" parent="." instance=ExtResource("2_2nvfu")]

View file

@ -31,9 +31,11 @@ func _on_body_entered(body: Node2D):
if body.collision_layer & collecting_collision_mask:
var collectible: Collectible = body.get_node("Collectible")
if collectible.type in collecting_types:
print("collezionato")
collected_count += 1
collectible.collect()
emit_signal("collected", body)
if collected_count >= collecting_amount:
print("goal")
emit_signal("goal")
collected_count = 0

View file

@ -1,8 +1,15 @@
[gd_scene load_steps=2 format=3 uid="uid://c5w3b55aiui6c"]
[gd_scene load_steps=3 format=3 uid="uid://c5w3b55aiui6c"]
[ext_resource type="Script" path="res://collector/collector.gd" id="1_1xtt5"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vcox2"]
size = Vector2(113, 65)
[node name="Collector" type="Area2D"]
script = ExtResource("1_1xtt5")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(87.5, 48.5)
shape = SubResource("RectangleShape2D_vcox2")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]