Closed Oldes closed 11 years ago
Yeah - currently the Stroke class can only represent a single, unbroken line.
There's no reason it couldn't be made to handle gaps - it would certainly be more performant for situations like yours.
I'll stick this on my todo list - though no promises I'll get round to it anytime soon!
It would be big performance boost with complex shapes. But I understand that your usage scenarios are probably different;-)
If using the Stroke class directly, you now have access to stroke.addBreak(). So two unconnected vertical lines could be drawn like this
var stroke:Stroke = new Stroke()
addChild(stroke)
stroke.addVertex( 0, 0 );
stroke.addVertex( 0, 100 );
stroke.addBreak();
stroke.addVertex( 10, 0 );
stroke.addVertex( 10, 100 );
stroke.addBreak();
I've not got round to implementing this via the graphics API yet. I'll close this issue once this is done.
This has now been added with the following commit https://github.com/unwrong/Starling-Extension-Graphics/commit/c1ce13c8832080db8e2b036412136f37839261d1
Be aware that a single Stroke can only support a single lineStyle. Multiple calls to lineTo() and moveTo() will use a single stroke until one of the lineStyle() functions are called, at which point a new Stroke object is created and you lose a little bit of performance. So if you're drawing loads of lines, batching similar colours/materials together will give you much better performance.
Hi, it's me again:) I've noticed, that when I call just:
g.lineStyle(20, 0xFF0000) g.lineTo(100, 0); g.moveTo(0, 100); g.lineTo(100, 100);
in the g's container I will have 2 stroke objects. Woudn't it be better to have just one in such a case?