Hi,everybody.I have a question. There are any solution to implement a feature like this gif?
Thanks for any reply
Hi,everybody.I have a question. There are any solution to implement a feature like this gif?
Thanks for any reply
You can use a Line2D node, and then move it around by altering its global_position
so it follows the mouse's global position. You may need to do some minor amounts of additional processing to account for the offset of the mouse position and the Line2D node's origin, but it should be doable.
@TwistedTwigleg said: You can use a Line2D node, and then move it around by altering its
global_position
so it follows the mouse's global position. You may need to do some minor amounts of additional processing to account for the offset of the mouse position and the Line2D node's origin, but it should be doable.
Ye, that shound good, but another questions is how to detect the user click on the line.The Process in my mind is :when left mouse button just_pressed
, if mouse position in the line area , i will move line follow the mouse position. But I don’t know how to detect whether the point is in the line area. create a CollisionPolygon2D
around the line ? what polygon
the collision need
@TwistedTwigleg
em, thanks for your suggestion. And i solved it,by use Line2D
and CollisionPolygon2D
.
To avoid someone having the same question, I pushed the demo which I implemented this to Github, hope it helps https://github.com/ning-drift/clickable_line