Cocos2d 1.0到cocos2d 2.0源端口

时间:2013-06-10 17:29:02

标签: cocos2d-iphone

我在cocos2d 1.0中有以下功能,它没有在cocos2d 2.0中编译。

任何人都可以帮助我为cocos2d 2.0获得相同的功能。

void ccFillPoly( CGPoint *poli, int points, BOOL closePolygon )
{
    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    glVertexPointer(2, GL_FLOAT, 0, poli);
    if( closePolygon )
        glDrawArrays(GL_TRIANGLE_FAN, 0, points);
    else
        glDrawArrays(GL_LINE_STRIP, 0, points);

    // restore default state
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);
}

1 个答案:

答案 0 :(得分:2)

cocos2d 2.x提供了绘制OpenGL ES基元的函数。头文件是 CCDrawingPrimitives.h

/** draws a solid polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color.
*/
void ccDrawSolidPoly( const CGPoint *poli, NSUInteger numberOfPoints, ccColor4F color );