【问题标题】:How to efficiently draw multiple primitives in cocos2d-iphone?cocos2d-iphone中如何高效绘制多个图元?
【发布时间】:2012-05-01 10:26:48
【问题描述】:

我正在玩 cocos2d-iphone,它看起来很棒!

但我想为每次更新在屏幕上绘制另一个圆圈,这会非常快地降低帧速率! 我可以以更快的方式绘制多个图元吗?

这是我目前使用的代码

-(void) draw
{
    glLineWidth(1);
    glColor4ub(100,100,255,0);
    float angle = 0;
    float radius = 10.0f;
    int numSegments = 10;
    bool drawLineToCenter = NO;

    NSInteger point;
    for (point=0;point < [points count];point++)
    {
        ccDrawCircle([[points objectAtIndex:point] CGPointValue], radius, angle, numSegments, drawLineToCenter);

    }
}

【问题讨论】:

    标签: opengl-es cocos2d-iphone


    【解决方案1】:

    使用精灵而不是图元。然后你可以使用 CCSpriteBatchNode。

    cocos2d 的原始绘制方法主要是为了调试目的,而不是为了弥补你的游戏艺术。主要它们不是批处理操作,这意味着您绘制的每个新图元都会发出一次绘制调用。而且很贵。

    【讨论】:

      猜你喜欢
      • 2012-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 2017-03-21
      • 1970-01-01
      相关资源
      最近更新 更多