From 5a13cabece1147349257393ab3db71606484020b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 Apr 2022 03:14:48 +0200 Subject: [PATCH] :wrench: Nest nodes in a smarter way --- src/entities/Bullet.tscn | 15 ++++++++------- src/entities/Enemy.tscn | 12 ++++++------ src/entities/Fire.tscn | 12 ++++++------ src/entities/Player.tscn | 10 +++++----- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/entities/Bullet.tscn b/src/entities/Bullet.tscn index 0e2c08b..25c31ce 100644 --- a/src/entities/Bullet.tscn +++ b/src/entities/Bullet.tscn @@ -4,17 +4,18 @@ [ext_resource path="res://src/entities/behaviours/BulletMovement.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 16, 8 ) [node name="Bullet" type="KinematicBody2D"] collision_layer = 2 -[node name="BulletMovement" type="Node" parent="."] -script = ExtResource( 2 ) - -[node name="Sprite" type="Sprite" parent="."] -scale = Vector2( 1, 0.5 ) -texture = ExtResource( 1 ) - [node name="Shape" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) disabled = true + +[node name="Sprite" type="Sprite" parent="Shape"] +scale = Vector2( 1, 0.5 ) +texture = ExtResource( 1 ) + +[node name="BulletMovement" type="Node" parent="."] +script = ExtResource( 2 ) diff --git a/src/entities/Enemy.tscn b/src/entities/Enemy.tscn index e8cfd88..26cc8a3 100644 --- a/src/entities/Enemy.tscn +++ b/src/entities/Enemy.tscn @@ -9,12 +9,12 @@ extents = Vector2( 16, 16 ) [node name="Enemy" type="KinematicBody2D"] +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) + +[node name="Sprite" type="Sprite" parent="Shape"] +texture = ExtResource( 1 ) + [node name="AttractedTo" parent="." instance=ExtResource( 3 )] [node name="ErraticMovement" parent="." instance=ExtResource( 2 )] - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 1 ) - -[node name="Shape" type="CollisionShape2D" parent="."] -shape = SubResource( 1 ) diff --git a/src/entities/Fire.tscn b/src/entities/Fire.tscn index 12a0c6f..71b560b 100644 --- a/src/entities/Fire.tscn +++ b/src/entities/Fire.tscn @@ -10,13 +10,13 @@ extents = Vector2( 16, 16 ) [node name="Fire" type="StaticBody2D"] script = ExtResource( 3 ) +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) + +[node name="Sprite" type="Sprite" parent="Shape"] +texture = ExtResource( 2 ) + [node name="Light" type="Light2D" parent="."] texture = ExtResource( 1 ) texture_scale = 0.5 color = Color( 1, 0.592157, 0.592157, 1 ) - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 2 ) - -[node name="Shape" type="CollisionShape2D" parent="."] -shape = SubResource( 1 ) diff --git a/src/entities/Player.tscn b/src/entities/Player.tscn index 9074351..c9d0654 100644 --- a/src/entities/Player.tscn +++ b/src/entities/Player.tscn @@ -9,12 +9,12 @@ extents = Vector2( 16, 16 ) [node name="Player" type="KinematicBody2D"] -[node name="PlayerMovement" parent="." instance=ExtResource( 2 )] - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 1 ) - [node name="Shape" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) +[node name="Sprite" type="Sprite" parent="Shape"] +texture = ExtResource( 1 ) + +[node name="PlayerMovement" parent="." instance=ExtResource( 2 )] + [node name="BulletSpawn" parent="." instance=ExtResource( 3 )]