diff options
author | Logan <logan@cflip.net> | 2022-09-23 22:51:09 -0600 |
---|---|---|
committer | Logan <logan@cflip.net> | 2022-09-23 22:51:09 -0600 |
commit | c67cf0598998b3974a4e472a2570c404d83bd80e (patch) | |
tree | 50067ed9a90e81692bfa29356dfc01650f9e5630 | |
parent | 31889ce9c6604d5cdf42951c9991d15ff9077da2 (diff) |
Added one-way collision and area detection to hoop.
-rw-r--r-- | scenes/hoop.tscn | 25 | ||||
-rw-r--r-- | scripts/hoop.gd | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/scenes/hoop.tscn b/scenes/hoop.tscn index ddd8c5b..537589a 100644 --- a/scenes/hoop.tscn +++ b/scenes/hoop.tscn @@ -1,14 +1,23 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://textures/hoop_fore.png" type="Texture" id=1] [ext_resource path="res://textures/hoop_back.png" type="Texture" id=2] +[ext_resource path="res://scripts/hoop.gd" type="Script" id=3] [sub_resource type="SegmentShape2D" id=1] a = Vector2( 12, -21.6 ) b = Vector2( -4.6, 11.4 ) +[sub_resource type="RectangleShape2D" id=2] +extents = Vector2( 9.9, 0.55 ) + +[sub_resource type="SegmentShape2D" id=3] +a = Vector2( -4.4, -1 ) +b = Vector2( 17.4, -1 ) + [node name="Hoop" type="StaticBody2D"] scale = Vector2( 5, 5 ) +script = ExtResource( 3 ) [node name="BackgroundSprite" type="Sprite" parent="."] light_mask = 4 @@ -29,3 +38,17 @@ position = Vector2( -21.8, 6.6 ) rotation = 0.546288 scale = Vector2( 0.5, 1 ) polygon = PoolVector2Array( 0.762794, -5.14728, 5.32917, 3.9975, 2.25312, 4.93263, -3.35769, 0.318554 ) + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +position = Vector2( -12.6, 10.75 ) +shape = SubResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( -6.2, 11.8 ) +rotation = 3.14159 +shape = SubResource( 3 ) +one_way_collision = true + +[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"] diff --git a/scripts/hoop.gd b/scripts/hoop.gd new file mode 100644 index 0000000..756501b --- /dev/null +++ b/scripts/hoop.gd @@ -0,0 +1,6 @@ +extends StaticBody2D + +signal score + +func _on_Area2D_body_exited(body): + emit_signal ("score") |