From be64f3d8d76a60d1b8928598c8a064ca863a6d06 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 00:25:13 +0200 Subject: [PATCH] implemented logic for manual and automatic spawner --- entity/coin_copper.tscn | 2 +- root.tscn | 13 ++++++++++++- spawner/spawner.gd | 1 + spawner/spawner.tscn | 6 ------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/entity/coin_copper.tscn b/entity/coin_copper.tscn index a788a5f..034efc9 100644 --- a/entity/coin_copper.tscn +++ b/entity/coin_copper.tscn @@ -5,7 +5,7 @@ [ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] -size = Vector2(16, 5) +size = Vector2(14, 3) [node name="CoinCopper" type="RigidBody2D"] collision_layer = 5 diff --git a/root.tscn b/root.tscn index b24a08c..35ea7ee 100644 --- a/root.tscn +++ b/root.tscn @@ -79,6 +79,17 @@ texture_filter = 1 [node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] [node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -400) +position = Vector2(-24, -407) scene = ExtResource("2_dv01l") target_parent = NodePath("..") + +[node name="Timer2" type="Timer" parent="UI/GameContainer/Game/Spawner"] +autostart = true + +[node name="TouchSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(23, -424) +scene = ExtResource("2_dv01l") +target_parent = NodePath("..") + +[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/TouchSpawner" method="spawn"] +[connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer2" to="UI/GameContainer/Game/Spawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index be94ffb..de26e49 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -9,3 +9,4 @@ func spawn(): var scene_instant = scene.instantiate() scene_instant.position=Vector2.ZERO add_child(scene_instant) + diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index 399531f..fd59048 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -8,15 +8,9 @@ size = Vector2(16, 5) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") -[node name="Timer" type="Timer" parent="."] -wait_time = 0.1 -autostart = true - [node name="Area" type="Area2D" parent="."] collision_mask = 4 [node name="CoinShape" type="CollisionShape2D" parent="Area"] scale = Vector2(3, 3) shape = SubResource("RectangleShape2D_p13i4") - -[connection signal="timeout" from="Timer" to="." method="spawn"]