0 votes

I created a new thread because is a different question but there are more info about in this question:
https://godotengine.org/qa/94718/implement-a-kind-of-drag-and-move-action

Right now I have a line which following mouse and is a child of an empty label, so to draw only inside label's rect.
The hierarchy is like this:
-Board
--Backgound
--Letter1
--Letter2
....
--Letter7
--Label
---Line2D

The code for the line draw is _proccess in Board.gd script and the Letters are inherited scenes of a base Letter scene.

func _process(delta):
if WordUtils.dragging==true:
    for i in letternodes:
        if i.get_child(2).text !="":
            $Line/Line2D.add_point(get_global_mouse_position())
            #$Line/Line2D.add_point($Line/Line2D.to_local(i.get_child(0).to_global(position)))
            while $Line/Line2D.get_point_count() > trail_length:
                $Line/Line2D.remove_point(0)
else:
    $Line/Line2D.clear_points()

With the above the line draws everywhere inside the label's rect, after I press and hold mouse left button and start dragging.
This is fine, but I' d like to have drawing in a specific path from letter to letter and also to clear the line points in reverse direction moving following that path.
If I uncomment the line:

$Line/Line2D.add_point($Line/Line2D.to_local(i.get_child(0).to_global(position)))

and use this to draw the line this creates a polygon between letters centers(which is the correct path), but draws at once when I press mouse button.
So this is the correct path but I don't know how to draw this polygon gradually as dragging with the mouse left button pressed. And also to keep track of the path and clear the points as dragging in reverse direction.
To be more clear, when dragging from letter to letter I append the characters in a label every time the mouse enters a letter's area. So in reverse movement I want to remove the letter's character in order. Some kind of undo action.
Any ideas?

Godot version 3.2.3 stable
in Engine by (221 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.