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:
parent
bd3a764a80
commit
abc6b06654
3 changed files with 14 additions and 2 deletions
|
@ -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="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"]
|
[node name="Collectible" type="Node"]
|
||||||
script = ExtResource("1_qilbk")
|
script = ExtResource("1_qilbk")
|
||||||
|
|
||||||
|
[node name="Valuable" parent="." instance=ExtResource("2_2nvfu")]
|
||||||
|
|
|
@ -31,9 +31,11 @@ func _on_body_entered(body: Node2D):
|
||||||
if body.collision_layer & collecting_collision_mask:
|
if body.collision_layer & collecting_collision_mask:
|
||||||
var collectible: Collectible = body.get_node("Collectible")
|
var collectible: Collectible = body.get_node("Collectible")
|
||||||
if collectible.type in collecting_types:
|
if collectible.type in collecting_types:
|
||||||
|
print("collezionato")
|
||||||
collected_count += 1
|
collected_count += 1
|
||||||
collectible.collect()
|
collectible.collect()
|
||||||
emit_signal("collected", body)
|
emit_signal("collected", body)
|
||||||
if collected_count >= collecting_amount:
|
if collected_count >= collecting_amount:
|
||||||
|
print("goal")
|
||||||
emit_signal("goal")
|
emit_signal("goal")
|
||||||
collected_count = 0
|
collected_count = 0
|
||||||
|
|
|
@ -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"]
|
[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"]
|
[node name="Collector" type="Area2D"]
|
||||||
script = ExtResource("1_1xtt5")
|
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"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|
Loading…
Reference in a new issue