Prior to cocos2d-x 2.1.4, we were using cocos2d-x 2.0.4 and to get a stroke on text, I was using some code from here: http://www.cocos2d-x.org/boards/6/topics/22335
I wanted to add a gradient to the text, so I did this with a shader. The way I did it was to override the draw() method of the custom class I made, so it would set the shader program and then call CCLabelTTF’s draw() method.
With the update to cocos2d-x 2.1.4, I wanted to use the built-in stroke support instead. However, even though I have overridden the draw() method for the new custom class I made, the shader does not get used when a stroke is being applied. If no stoke is applied to the text, then the shader functions.
What I have for my code is this:
void CCLabelTTFWithGradient::draw()
{
@ if (this->program)@
@ {@
@ this~~>program~~>use();@
@ ccColor4F startColor = ccc4FFromccc3B(this~~>startGradientColor);@
@ ccColor4F endColor = ccc4FFromccc3B;@
@ this~~>program~~>setUniformLocationWith4f;@
@ this~~>program->setUniformLocationWith4f(this->endColorLocation, endColor.r, endColor.g, endColor.b, endColor.a);@
@ }@
@ CCLabelTTF::draw();@
}
Most of the variables are set in my own custom create() method. The above draw() method worked fine for me when I was using the code from that forum post, but as mentioned, it doesn’t work with the current CCLabelTTF when a stroke is used. Any help with this is appreciated.