- 我的平台:Mac
-cocos2d-x版本:3.8.1
-Tool:Xcode
-TestDevice:ios Simulator
我使用了这个链接enter link description here
我实现了刀片效果,就像在" Fruit Ninja App&#34 ;.
cocos2d-x3.0版本没问题。
但是...
CCBlade不适用于cocos2d-x 3.8版本。
帮助我〜
答案 0 :(得分: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);
}