From b636c3933418049f3cbc00952a5c6bc087b79b4e Mon Sep 17 00:00:00 2001 From: Moe Poi ~ Date: Wed, 25 Oct 2023 17:06:59 +0700 Subject: [PATCH] Add hover interaction to placement --- scenes/towers/placement/placement.tscn | 4 +++- scripts/towers/placement/placement.gd | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scenes/towers/placement/placement.tscn b/scenes/towers/placement/placement.tscn index 36ed3c6..f958433 100644 --- a/scenes/towers/placement/placement.tscn +++ b/scenes/towers/placement/placement.tscn @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://n3s2excibc4g" path="res://assets/spritesheets/placement.png" id="2_06tg2"] [sub_resource type="CircleShape2D" id="CircleShape2D_hi6ti"] -radius = 18.1108 +radius = 32.0156 [node name="placement" type="StaticBody2D"] input_pickable = true @@ -18,3 +18,5 @@ texture = ExtResource("2_06tg2") shape = SubResource("CircleShape2D_hi6ti") [connection signal="input_event" from="." to="." method="_on_input_event"] +[connection signal="mouse_entered" from="." to="." method="_on_hold"] +[connection signal="mouse_exited" from="." to="." method="_on_release"] diff --git a/scripts/towers/placement/placement.gd b/scripts/towers/placement/placement.gd index d184fae..bcc6071 100644 --- a/scripts/towers/placement/placement.gd +++ b/scripts/towers/placement/placement.gd @@ -7,3 +7,9 @@ func _on_input_event(_viewport, event, _shape_idx): var mouse_click = event as InputEventMouseButton if mouse_click and mouse_click.button_index == 1 and mouse_click.pressed: on_placement.emit(global_position, get_instance_id()) + +func _on_hold(): + $Sprite2D.modulate = Color(0.243137, 0.243137, 0.243137, 1) + +func _on_release(): + $Sprite2D.modulate = Color(1, 1, 1, 1) \ No newline at end of file