Merge pull request #5558 from Dhilan007/develop_label

close #4276:fixed crash on CocoStudioGuiTest->LabelBMFontTest.
This commit is contained in:
James Chen 2014-03-05 15:24:36 +08:00
commit 20146c3ecb
1 changed files with 22 additions and 9 deletions

View File

@ -826,10 +826,13 @@ void Label::setColor(const Color3B& color)
void Label::updateColor() void Label::updateColor()
{ {
V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads(); if (nullptr == _textureAtlas)
auto count = _textureAtlas->getTotalQuads(); {
return;
}
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
// special opacity for premultiplied textures // special opacity for premultiplied textures
if (_isOpacityModifyRGB) if (_isOpacityModifyRGB)
{ {
@ -837,13 +840,23 @@ void Label::updateColor()
color4.g *= _displayedOpacity/255.0f; color4.g *= _displayedOpacity/255.0f;
color4.b *= _displayedOpacity/255.0f; color4.b *= _displayedOpacity/255.0f;
} }
for (int index=0; index<count; ++index)
cocos2d::TextureAtlas* textureAtlas;
V3F_C4B_T2F_Quad *quads;
for (const auto& batchNode:_batchNodes)
{ {
quads[index].bl.colors = color4; textureAtlas = batchNode->getTextureAtlas();
quads[index].br.colors = color4; quads = textureAtlas->getQuads();
quads[index].tl.colors = color4; auto count = textureAtlas->getTotalQuads();
quads[index].tr.colors = color4;
_textureAtlas->updateQuad(&quads[index], index); for (int index = 0; index < count; ++index)
{
quads[index].bl.colors = color4;
quads[index].br.colors = color4;
quads[index].tl.colors = color4;
quads[index].tr.colors = color4;
textureAtlas->updateQuad(&quads[index], index);
}
} }
} }