<small id='OEHvM'></small><noframes id='OEHvM'>

      <bdo id='OEHvM'></bdo><ul id='OEHvM'></ul>
    1. <tfoot id='OEHvM'></tfoot>
    2. <legend id='OEHvM'><style id='OEHvM'><dir id='OEHvM'><q id='OEHvM'></q></dir></style></legend>
    3. <i id='OEHvM'><tr id='OEHvM'><dt id='OEHvM'><q id='OEHvM'><span id='OEHvM'><b id='OEHvM'><form id='OEHvM'><ins id='OEHvM'></ins><ul id='OEHvM'></ul><sub id='OEHvM'></sub></form><legend id='OEHvM'></legend><bdo id='OEHvM'><pre id='OEHvM'><center id='OEHvM'></center></pre></bdo></b><th id='OEHvM'></th></span></q></dt></tr></i><div id='OEHvM'><tfoot id='OEHvM'></tfoot><dl id='OEHvM'><fieldset id='OEHvM'></fieldset></dl></div>

      ccDrawLine 不透明度?

      时间:2024-08-12
        <tbody id='iU8sU'></tbody>
        <bdo id='iU8sU'></bdo><ul id='iU8sU'></ul>

          <tfoot id='iU8sU'></tfoot>
        1. <i id='iU8sU'><tr id='iU8sU'><dt id='iU8sU'><q id='iU8sU'><span id='iU8sU'><b id='iU8sU'><form id='iU8sU'><ins id='iU8sU'></ins><ul id='iU8sU'></ul><sub id='iU8sU'></sub></form><legend id='iU8sU'></legend><bdo id='iU8sU'><pre id='iU8sU'><center id='iU8sU'></center></pre></bdo></b><th id='iU8sU'></th></span></q></dt></tr></i><div id='iU8sU'><tfoot id='iU8sU'></tfoot><dl id='iU8sU'><fieldset id='iU8sU'></fieldset></dl></div>

              <small id='iU8sU'></small><noframes id='iU8sU'>

              <legend id='iU8sU'><style id='iU8sU'><dir id='iU8sU'><q id='iU8sU'></q></dir></style></legend>
                本文介绍了ccDrawLine 不透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我对所有这些 OpenGL 调用都很陌生,但幸运的是 cocos2d 可以轻松让我在屏幕上画线,如下所示:

                I am very new to all those OpenGL calls, but fortunately cocos2d will easily let me draw lines on the screen, like this:

                -(void)draw {
                    glColor4f(255, 255, 255,255);
                    ccDrawLine(ccp(150,110), ccp(280,230));
                }
                

                我得到一条白线.

                但是现在,我想让它变得有点透明,所以我将 alpha 值更改为 100.但是,这条线仍然是亮白色的.然后我假设这些值实际上可以在 0.0 到 1.0 之间.我将它设置为 0.2 但仍然没有变化.

                But now, I want to make it a bit transparent, so I change the alpha value to 100. However, the line is still bright and white. Then I assumed that the values could actually range from 0.0 to 1.0. I set it to 0.2 but still no change.

                这是为什么呢?

                推荐答案

                你肯定需要先启用混合:

                You definitely need to enable blending first:

                glEnable(GL_BLEND);
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                glColor4ub(255, 255, 255,100);
                ccDrawLine(ccp(0,110), ccp(280,230));
                

                另请注意,glColor4ub"采用无符号字节(每个参数为 0-255),而"glColor4f" 接受 4 个浮点数(每个参数为 0-1.0).使用任何你觉得舒服的.

                Also note that "glColor4ub" takes in unsigned bytes (0-255 for each parameter) while "glColor4f" takes in 4 floats (0-1.0 for each parameter). Use whichever you are comfortable with.

                祝你好运!

                这篇关于ccDrawLine 不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:cocos2d 使用 CCSpeed 动态改变动画速度 下一篇:在 Cocos2d 中获取贝塞尔曲线问题的导数

                相关文章

                1. <tfoot id='MFB9f'></tfoot>

                      <bdo id='MFB9f'></bdo><ul id='MFB9f'></ul>

                    <small id='MFB9f'></small><noframes id='MFB9f'>

                    <i id='MFB9f'><tr id='MFB9f'><dt id='MFB9f'><q id='MFB9f'><span id='MFB9f'><b id='MFB9f'><form id='MFB9f'><ins id='MFB9f'></ins><ul id='MFB9f'></ul><sub id='MFB9f'></sub></form><legend id='MFB9f'></legend><bdo id='MFB9f'><pre id='MFB9f'><center id='MFB9f'></center></pre></bdo></b><th id='MFB9f'></th></span></q></dt></tr></i><div id='MFB9f'><tfoot id='MFB9f'></tfoot><dl id='MFB9f'><fieldset id='MFB9f'></fieldset></dl></div>
                    <legend id='MFB9f'><style id='MFB9f'><dir id='MFB9f'><q id='MFB9f'></q></dir></style></legend>