drawLine does draw a straight line between 2 points. It will look curved because your code draws lots of small lines that together look curved.
What exactly are you trying to do? Once the touch has ended, should there be only straight line, which is straight? Or should the path of the touch look like many lots of straight lines?
You could clear the DrawNode every time touch moves before you draw the line. It will clear the entire DrawNode, but if the line is the only thing you are drawing then that shouldn’t matter.
Yes @grimfate . I think Its great Idea but i already done that .For my Work this is not good because We have dots in grid like structure and I want to connects all when touch move from one dot to another.
drawnode->clear() clears everything.
I want to connect numbers when we move as shown above.
You could use multiple DrawNodes. Use the first DrawNode for drawing the line and clear it whenever the touch moves, and use the second DrawNode for drawing that you don’t want cleared.
If you want the line to remain after the touch ends, draw the line onto the second DrawNode when the touch ends and then clear the first DrawNode.