Add hover interaction to placement

This commit is contained in:
Moe Poi ~ 2023-10-25 17:06:59 +07:00
parent cf2c677cce
commit b636c39334
2 changed files with 9 additions and 1 deletions

View file

@ -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"]

View file

@ -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)