diff options
-rw-r--r-- | scenes/basketball.tscn | 15 | ||||
-rw-r--r-- | scripts/basketball.gd | 13 |
2 files changed, 20 insertions, 8 deletions
diff --git a/scenes/basketball.tscn b/scenes/basketball.tscn index 75a5e60..9f06c73 100644 --- a/scenes/basketball.tscn +++ b/scenes/basketball.tscn @@ -26,10 +26,17 @@ shape = SubResource( 1 ) scale = Vector2( 5, 5 ) texture = ExtResource( 1 ) -[node name="Area2D" type="Area2D" parent="."] +[node name="OuterShape" type="Area2D" parent="."] -[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="OuterShape"] shape = SubResource( 3 ) -[connection signal="mouse_entered" from="Area2D" to="." method="_on_Area2D_mouse_entered"] -[connection signal="mouse_exited" from="Area2D" to="." method="_on_Area2D_mouse_exited"] +[node name="InnerShape" type="Area2D" parent="."] + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="InnerShape"] +shape = SubResource( 1 ) + +[connection signal="mouse_entered" from="OuterShape" to="." method="on_OuterShape_mouse_entered"] +[connection signal="mouse_exited" from="OuterShape" to="." method="_on_OuterShape_mouse_exited"] +[connection signal="mouse_entered" from="InnerShape" to="." method="_on_InnerShape_mouse_entered"] +[connection signal="mouse_exited" from="InnerShape" to="." method="_on_InnerShape_mouse_exited"] diff --git a/scripts/basketball.gd b/scripts/basketball.gd index f9fd4a1..d4a5a66 100644 --- a/scripts/basketball.gd +++ b/scripts/basketball.gd @@ -9,6 +9,7 @@ var power var power_magnitude = 10 var spin_rotation = 0 var ready_to_shoot +var ready_to_hold func _ready(): start_position = position @@ -45,11 +46,15 @@ func _process(delta): func _input(event): if event.is_action_released("shoot"): if ready_to_shoot or !waiting_for_shoot: - power = (position - event.position) * power_magnitude + power = (start_position - event.position) * power_magnitude toggle_mode() -func _on_Area2D_mouse_entered(): +func on_OuterShape_mouse_entered(): ready_to_shoot = true - -func _on_Area2D_mouse_exited(): +func _on_OuterShape_mouse_exited(): ready_to_shoot = false + +func _on_InnerShape_mouse_entered(): + ready_to_hold = true +func _on_InnerShape_mouse_exited(): + ready_to_hold = false |