How do I create a system that creates a line that drags across a grid (like the photo attached)? I know I need to use things like Shape Painter but I have no idea how to execute it. Thanks!
If you’re planning to make a game like the one in the image, then it’d probably be easier to to have a series of predefined sprites instead of drawing lines.
You could get away with 3 white sprites - one for when the line is dragged into a square (so from edge to centre), one for a straight line through and one that is an elbow. By rotating them and changing the tint, you can create the lines that connect any 2 points for any colour.
I could do that, but it’d also be hard to track where the mouse is going and translating that to sprite creation. That’s mainly where I’m having problems - I don’t know how to track what tiles the mouse has been on and how to use that to draw lines.
It may not be as hard as you think. Give each tile a unique id, and use an array to track each tile as the mouse goes over it. When a new valid tile has the mouse over it, add it to the array. If it’s the same as the second-to-last one added, then remove the last one.
Then just go over each tile id in the array and determine it’s image based on the previous and next id in the array. Slightly different rules for the first and last tile ids, but definitely do-able.
Just thinking about it, you could apply the same technique for drawing lines instead of sprites…
okay I’m gonna be honest - I have no idea how to use arrays or anything like that. I think I know what you mean, but I have no idea how to implement that sort of thing. Some help would be greatly appreciated LOL!