From d98cee8592e15f23ce85e8d54abb29aa341c97da Mon Sep 17 00:00:00 2001 From: perivesta <> Date: Sat, 8 Jul 2023 16:13:25 +0200 Subject: start drawing when clicking on start. end at finish --- Scripts/drawing.gd | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'Scripts/drawing.gd') diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd index 2e4af95..51e7f21 100644 --- a/Scripts/drawing.gd +++ b/Scripts/drawing.gd @@ -14,19 +14,21 @@ func _process(delta): func _physics_process(delta): pass + +func _start_drawing(): + line.clear_points() + path.curve.clear_points() + drawing = true + owner.set_driving(false) + + +func _end_drawing(): + drawing = false + owner.set_driving(true) + + func _input(event): - if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: - drawing = event.pressed - if drawing: - # start a new drawing - line.clear_points() - path.curve.clear_points() - owner.set_driving(false) - else: - # start driving - owner.set_driving(true) - - if event is InputEventMouseMotion and drawing: - # extend the line + if drawing and event is InputEventMouseMotion: line.add_point(event.position) path.curve.add_point(event.position) + -- cgit