【问题标题】:Drawing with cocos2d用 cocos2d 绘图
【发布时间】:2013-12-19 00:32:58
【问题描述】:

我重写了 CCLayerColor 的 draw 方法来绘制边框,但是颜色没有改变。我试过 ccDrawXxxx 并且他们都只使用白色作为颜色。我也试过glColor4ub 有同样的效果。这就是我的 draw 方法的全部内容:

CGSize selfSize = [self contentSize];
float selfHeight = selfSize.height;
float selfWidth = selfSize.width;
CGPoint vertices[4] = {ccp(0.f, 0.f), ccp(0.f, selfHeight), ccp(selfWidth, selfHeight), ccp(selfWidth, 0.f)};

glColor4f(0, 0, 1.0f, 1.0f);
glLineWidth(4.0f);
ccDrawPoly(vertices, 4, YES);

我错过了什么吗?我正在使用 v2.0。

【问题讨论】:

    标签: cocos2d-iphone cclayer


    【解决方案1】:

    这应该可行:

    ccDrawColor(1, 0, 0, 1);
    ccDrawSomething(…);
    

    您不应该在 cocos2d 2.0 中使用 GLES 1.1 方法,例如 glColor4f 和 glLineWidth。也许这会导致 OpenGL 错误以某种方式影响 GL 状态。

    【讨论】:

    • ccDrawColor(1, 0, 0, 1) 是我所需要的,感谢您的提示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多