So, here's an outline to accomplish what you want...
- Create your sprite so it the "arm" is an independent piece
- Make the "arm" a child of the main sprite, with its pivot point being at the "shoulder" joint (with that, the arm should be able to rotate naturally.
- Attach an
Area2D to the "hand" end of the arm (as a child of the arm sprite)
- Add a
CollisionShape2D as a child of the
Area2D. Looking at your picture, you'll want that to be a big circle. This is what will detect the mouse-clicks.
- Wire the
input_event signal on the
Area2D to a script handler. This script will be called when the
Area2D is clicked.
- In that script, rotate your arm as needed.
Here's a sample scene tree:
+ Body (sprite)
+ Arm (sprite)
+ HitBox (area2d)
And a sample input handler script (though it only rotates the arm by 10 degrees in one direction with each click).
func _on_Area2D_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton and event.pressed and event.button_index == 1:
$Body/Arm.rotation_degrees += 10