I am trying to figure out what is the best way to draw a line between two SKNodes in SpriteKit, nodes that move each frame. [Example sketch below... the red line is what I want to draw]
I can draw a line. At the moment I override the update call and every frame I detect the position of the two nodes (P1 and P2), and then simply draw a line [using an SKShapeNode and creating the path that goes from P1 to P2 then setting the shape node's path to it...].
It works and it performs well. However, that is handling two nodes, one line that visually connects them. What I am going to need is two draw multiple lines between multiple nodes. I feel like it'll be cumbersome to do so for N nodes to loop through each case every frame and remove and redraw lines.
I am wondering if there is a way to leverage physics body and joint to "add" a line between two nodes once and then have sprit kit handle the updates as the nodes move.
So, what is the best way to show lines between nodes that moves around every frame instead of having to loop through them each frame to redraw the line nodes as I get more nodes to handle?