Browse Source

:truck: Move ball catcher into a dedicated scene

DricomDragon 3 years ago
parent
commit
8fe66e4ee5

+ 1 - 1
godot/component/entity/catcher/Catcher.gd

@@ -5,7 +5,7 @@ signal kace_catch
 signal game_over
 
 func _on_Catcher_body_entered(body):
-	# TODO Debug game over signal
+	# TODO Debug game over signal not detected
 	if body.is_in_group("ball"):
 		body.queue_free()
 		emit_signal("kace_catch")

+ 19 - 0
godot/component/entity/catcher/Catcher.tscn

@@ -0,0 +1,19 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://component/entity/catcher/Catcher.gd" type="Script" id=1]
+
+[sub_resource type="RectangleShape2D" id=1]
+extents = Vector2( 200, 50 )
+
+[node name="Catcher" type="Area2D"]
+position = Vector2( 200, 460 )
+collision_layer = 8
+collision_mask = 5
+script = ExtResource( 1 )
+__meta__ = {
+"_editor_description_": "Ball catcher"
+}
+
+[node name="Area" type="CollisionShape2D" parent="."]
+shape = SubResource( 1 )
+[connection signal="body_entered" from="." to="." method="_on_Catcher_body_entered"]

+ 3 - 15
godot/main.tscn

@@ -1,8 +1,8 @@
-[gd_scene load_steps=15 format=2]
+[gd_scene load_steps=14 format=2]
 
 [ext_resource path="res://component/ui/message_panel/MessagePanel.tscn" type="PackedScene" id=1]
 [ext_resource path="res://component/entity/launcher/TargetLine.gd" type="Script" id=2]
-[ext_resource path="res://component/entity/catcher/Catcher.gd" type="Script" id=3]
+[ext_resource path="res://component/entity/catcher/Catcher.tscn" type="PackedScene" id=3]
 [ext_resource path="res://component/ui/LifeContainer.gd" type="Script" id=4]
 [ext_resource path="res://component/ui/UI.gd" type="Script" id=5]
 [ext_resource path="res://component/ui/number_panel/NumberPanel.tscn" type="PackedScene" id=6]
@@ -14,9 +14,6 @@
 [ext_resource path="res://component/entity/brick/Grid.gd" type="Script" id=12]
 [ext_resource path="res://component/entity/border/Border.tscn" type="PackedScene" id=13]
 
-[sub_resource type="RectangleShape2D" id=4]
-extents = Vector2( 200, 50 )
-
 [node name="Game" type="Node"]
 
 [node name="Background" type="Panel" parent="."]
@@ -28,14 +25,7 @@ __meta__ = {
 
 [node name="Border" parent="." instance=ExtResource( 13 )]
 
-[node name="Catcher" type="Area2D" parent="."]
-position = Vector2( 200, 460 )
-collision_layer = 8
-collision_mask = 5
-script = ExtResource( 3 )
-
-[node name="Area" type="CollisionShape2D" parent="Catcher"]
-shape = SubResource( 4 )
+[node name="Catcher" parent="." instance=ExtResource( 3 )]
 
 [node name="Launcher" type="Node2D" parent="."]
 script = ExtResource( 8 )
@@ -112,8 +102,6 @@ margin_right = 50.0
 margin_bottom = 390.0
 title = "Balls"
 [connection signal="ready" from="." to="UI/BallCounter" method="increase_counter"]
-[connection signal="body_entered" from="Catcher" to="Catcher" method="_on_Catcher_body_entered"]
-[connection signal="game_over" from="Catcher" to="UI" method="_on_Catcher_game_over"]
 [connection signal="gain_new_bullet" from="Launcher" to="UI/BallCounter" method="increase_counter"]
 [connection signal="get_firing" from="Launcher" to="UI" method="_on_Launcher_get_firing"]
 [connection signal="get_firing" from="Launcher" to="Launcher" method="_on_Launcher_get_firing"]