fixed logical error.

This commit is contained in:
Dhilan007 2014-03-31 15:45:06 +08:00
parent 774debd142
commit 89eba4424f
2 changed files with 24 additions and 3 deletions

View File

@ -345,7 +345,7 @@ void Label::reset()
_shadowEnabled = false;
_clipEnabled = false;
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
_blendFuncDirty = false;
}
void Label::updateShaderProgram()
@ -1014,7 +1014,10 @@ void Label::createSpriteWithFontDefinition()
_textSprite->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
this->setContentSize(_textSprite->getContentSize());
texture->release();
_textSprite->setBlendFunc(_blendFunc);
if (_blendFuncDirty)
{
_textSprite->setBlendFunc(_blendFunc);
}
Node::addChild(_textSprite,0,Node::INVALID_TAG);
@ -1086,7 +1089,10 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
if (_shadowEnabled && _shadowNode == nullptr)
{
_shadowNode = Sprite::createWithTexture(_textSprite->getTexture());
_shadowNode->setBlendFunc(_blendFunc);
if (_shadowNode)
{
_shadowNode->setBlendFunc(_blendFunc);
}
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_effectColorF.a * _displayedOpacity);
@ -1392,4 +1398,17 @@ void Label::listenToFontAtlasPurge(EventCustom *event)
}
}
void Label::setBlendFunc(const BlendFunc &blendFunc)
{
_blendFunc = blendFunc;
_blendFuncDirty = true;
if (_textSprite)
{
_textSprite->setBlendFunc(blendFunc);
if (_shadowNode)
{
_shadowNode->setBlendFunc(blendFunc);
}
}
}
NS_CC_END

View File

@ -255,6 +255,7 @@ public:
*/
void listenToFontAtlasPurge(EventCustom *event);
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
protected:
void onDraw(const kmMat4& transform, bool transformUpdated);
@ -378,6 +379,7 @@ protected:
Color4F _textColorF;
bool _clipEnabled;
bool _blendFuncDirty;
private:
CC_DISALLOW_COPY_AND_ASSIGN(Label);