There's a bunch of ways you could do it, and it depends on your needs, but I'd consider:
- OpenGL line code
- Looks like poo
- Use the Ribbon class in the experimental folder
- Has problems with folding over itself
- Draw it like a paint stroke in an art package
I'd personally use the third, since it would give you a lot of control of how the line looks. There are numerous ways to do this, but I'll outline the quickest balance between speed of implementation and performance for you here:
- Look up my RenderTexture class on the old forums and add it to your project
- Create a brush sprite (white with alpha)
- Construct a RenderTexture and add it to your scene
- When the user moves, pass the old and new location of the touch into a function
- call begin on the render texture
- iterate from the start position to the end position
- set the position of the brush to the current drawing position
- call visit on the brush
- call end on the render texture
This will effectively draw your brush into the render texture from the previous position to the next position. The render texture will consume a bunch of memory, but the line will be fast to draw regardless of how long or complex it becomes since it gets baked into the texture. Best of all, the line can look like a true brush stroke, and you can vary all kinds of ways you draw it to create textural or color effects. To optimize, you could lower the res of the render texture or use a particle system to draw instead of a sprite (add a particle per point instead of calling visit over and over).