Game Development Reference
In-Depth Information
int numTriangles = _numVertices - 2;
CCRenderBuffer buffer = [renderer
enqueueTriangles:numTriangles
andVertexes:_numVertices
withState:self.renderState
globalSortOrder:0];
int i = 0;
CGPoint centerPos = ((CCNode*)_children[0]).position;
for (CCNode* child in _children)
{
CGPoint vertexPos = child.position;
if (i > 0)
{
CGPoint vectorToCenter = ccpSub(child.position,
centerPos);
CGFloat length = ccpLength(vectorToCenter);
CGPoint normalVector = ccpMult(vectorToCenter,
1.0 / length);
vectorToCenter = ccpMult(normalVector, length +
_enlargeDrawRadius);
vertexPos = ccpAdd(vectorToCenter, centerPos);
}
_vertices[i].position = GLKVector4Make(vertexPos.x,
vertexPos.y,
0.0, 1.0);
CCVertex v = CCVertexApplyTransform(_vertices[i],
transform);
CCRenderBufferSetVertex(buffer, i, v);
i++;
}
int lastIndex = _numVertices - 1;
_vertices[lastIndex].position = GLKVector4Make(
_vertices[1].position.x,
_vertices[1].position.y,
0.0, 1.0);
CCVertex v =
CCVertexApplyTransform(_vertices[lastIndex],
Search WWH ::




Custom Search