Can you tell me what is the best way to draw a line or rectangle on the stage using Cocos2d ios4 iphone.
Still tried Texture2d, but it looks more like a brush and not very good. I tried to draw a line using the draw method, but the previous line disappears when I draw another line.
In principle, you need to draw several horizontal, vertical, inclined beams. Please suggest. Any code will help a lot.
The code for drawing using the texture below:
CGPoint start = edge.start;
CGPoint end = edge.end;
[target begin];
float distance = ccpDistance(start, end);
if (distance > 1)
{
int d = (int)distance;
for (int i = 0; i < d; i++)
{
float difx = end.x - start.x;
float dify = end.y - start.y;
float delta = (float)i / distance;
[brush setPosition:ccp(start.x + (difx * delta), start.y + (dify * delta))];
[brush setScale:0.3];
[brush visit];
}
}
[target end];
The rendering is not very good. with slanted lines, because scaling affects quality.
Greetings
source
share