【问题标题】:CCBlade does not work on the cocos2d-x 3.8 versionCCBlade 不支持 cocos2d-x 3.8 版本
【发布时间】:2015-12-02 08:32:19
【问题描述】:

-我的平台:Mac

-cocos2d-x 版本:3.8.1

-工具:Xcode

-TestDevice : ios 模拟器

我使用了这个链接enter link description here

我实现了刀片效果,就像在“水果忍者应用程序”中一样。

在cocos2d-x3.0版本上没问题。

但是……

CCBlade 不适用于 cocos2d-x 3.8 版本。

帮帮我~

【问题讨论】:

    标签: ios cocos2d-x cocos2d-x-3.x


    【解决方案1】:

    试试这个:

    void Blade::onDraw(const Mat4 &transform, uint32_t flags)
    {
        getGLProgram()->use();
        getGLProgram()->setUniformsForBuiltins(transform);
    
        GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_TEX_COORD|GL::VERTEX_ATTRIB_FLAG_POSITION);
    
        GL::blendFunc(_blendFunc.src,_blendFunc.dst);
    
        GL::bindTexture2D( _texture->getName() );
    
        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _coordinates);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)(2 * _path.size() - 2));
        CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, (2 * _path.size() - 2));
    }
    void Blade::draw(Renderer *renderer, const Mat4 &transform,uint32_t flags)
    {
        if ((_reset && _path.size() > 0) || (_autoDim && _willPop))
        {
            pop(1);
            if (_path.size() < 3)
            {
                clear();
            }
        }
    
        if (_path.size() < 3)
        {
            return;
        }
    
        _willPop = true;
    
         CCASSERT(_texture, "NO TEXTURE SET");
        _custumCamand.init(_globalZOrder,transform,flags);
        _custumCamand.func = CC_CALLBACK_0(Blade::onDraw,this,transform,flags);
        renderer->addCommand(&_custumCamand);
    }
    

    【讨论】:

      猜你喜欢
      • 2020-01-24
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-16
      相关资源
      最近更新 更多