如何ccDrawPoly和填充?

时间:2012-10-23 21:30:44

标签: cocos2d-iphone opengl-es-2.0

- (void)draw {
lines[0] = ccp(self.l.x + (segmentIndex[0] * segmentSpacing), self.l.y);
lines[1] = ccp(self.l.x + (segmentIndex[1] * segmentSpacing), self.l.y + segmentHeight * 1);
lines[2] = ccp(self.l.x + (segmentIndex[2] * segmentSpacing), self.l.y + segmentHeight * 2);
lines[3] = ccp(self.l.x + (segmentIndex[3] * segmentSpacing), self.l.y + segmentHeight * 3);
lines[4] = ccp(lines[3].x + segmentWidth, lines[3].y);
lines[5] = ccp(lines[2].x + segmentWidth, lines[2].y);
lines[6] = ccp(lines[1].x + segmentWidth, lines[1].y);
lines[7] = ccp(lines[0].x + segmentWidth, lines[0].y);

ccDrawPoly(lines, 8, YES);
//ccDrawSolidPoly(lines, 8, [self color]);

}

ccDrawPoly线绘制我打算绘制的锯齿形样式。 有4个Y段,每个段都有一个由segmentIndex& segmentSpacing,然后是x上的+ segmentWidth,总共8个点。 我先走到最左边的点,然后再向前走。

当我调用ccDrawSolidPoly时,它会以不同的方式填充形状。它使用所有最外面的点填充多边形,而不是按照我在点中设置的顺序绘制线条。

如何进行ccDrawPoly和填充?

1 个答案:

答案 0 :(得分:0)

显然写下我自己的功能。

论坛结果显示人们编辑cocos2d ccDrawSolidPoly函数。