mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6089 from Dhilan007/develop_label
Fixed logical error in Label::enableShadow
This commit is contained in:
commit
c3334cb4ac
|
@ -871,15 +871,10 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const
|
|||
_fontDefinition._shadow._shadowEnabled = false;
|
||||
_shadowDirty = true;
|
||||
|
||||
_effectColor = shadowColor;
|
||||
_effectColorF.r = _effectColor.r / 255.0f;
|
||||
_effectColorF.g = _effectColor.g / 255.0f;
|
||||
_effectColorF.b = _effectColor.b / 255.0f;
|
||||
_effectColorF.a = _effectColor.a / 255.0f;
|
||||
|
||||
_shadowColor.r = _effectColor.r;
|
||||
_shadowColor.g = _effectColor.g;
|
||||
_shadowColor.b = _effectColor.b;
|
||||
_shadowColor.r = shadowColor.r;
|
||||
_shadowColor.g = shadowColor.g;
|
||||
_shadowColor.b = shadowColor.b;
|
||||
_shadowOpacity = shadowColor.a / 255.0f;
|
||||
|
||||
auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
|
||||
_shadowOffset.width = offset.width * contentScaleFactor;
|
||||
|
@ -890,7 +885,7 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const
|
|||
if (_textSprite && _shadowNode)
|
||||
{
|
||||
_shadowNode->setColor(_shadowColor);
|
||||
_shadowNode->setOpacity(_effectColorF.a * _displayedOpacity);
|
||||
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
|
||||
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +965,7 @@ void Label::drawShadowWithoutBlur()
|
|||
{
|
||||
Color3B oldColor = _realColor;
|
||||
GLubyte oldOPacity = _displayedOpacity;
|
||||
_displayedOpacity = _effectColorF.a * _displayedOpacity;
|
||||
_displayedOpacity = _shadowOpacity * _displayedOpacity;
|
||||
setColor(_shadowColor);
|
||||
|
||||
_shaderProgram->setUniformsForBuiltins(_shadowTransform);
|
||||
|
@ -1093,7 +1088,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
|
|||
}
|
||||
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
|
||||
_shadowNode->setColor(_shadowColor);
|
||||
_shadowNode->setOpacity(_effectColorF.a * _displayedOpacity);
|
||||
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
|
||||
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
|
||||
Node::addChild(_shadowNode,0,Node::INVALID_TAG);
|
||||
}
|
||||
|
|
|
@ -376,6 +376,7 @@ protected:
|
|||
int _shadowBlurRadius;
|
||||
kmMat4 _shadowTransform;
|
||||
Color3B _shadowColor;
|
||||
float _shadowOpacity;
|
||||
Sprite* _shadowNode;
|
||||
|
||||
Color4B _textColor;
|
||||
|
|
|
@ -1308,14 +1308,21 @@ LabelShadowTest::LabelShadowTest()
|
|||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,true);
|
||||
|
||||
shadowLabelTTF = Label::createWithTTF(ttfConfig,"TTF:Shadow", TextHAlignment::CENTER, size.width);
|
||||
shadowLabelTTF->setPosition( Point(size.width/2, size.height*0.6f) );
|
||||
shadowLabelTTF = Label::createWithTTF(ttfConfig,"TTF:Shadow");
|
||||
shadowLabelTTF->setPosition( Point(size.width/2, size.height*0.65f) );
|
||||
shadowLabelTTF->setTextColor( Color4B::RED );
|
||||
shadowLabelTTF->enableShadow(Color4B::BLACK);
|
||||
addChild(shadowLabelTTF);
|
||||
|
||||
shadowLabelOutline = Label::createWithTTF(ttfConfig,"TTF:Shadow");
|
||||
shadowLabelOutline->setPosition( Point(size.width/2, size.height*0.5f) );
|
||||
shadowLabelOutline->setTextColor( Color4B::RED );
|
||||
shadowLabelOutline->enableOutline(Color4B::YELLOW,1);
|
||||
shadowLabelOutline->enableShadow(Color4B::BLACK);
|
||||
addChild(shadowLabelOutline);
|
||||
|
||||
shadowLabelBMFont = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "BMFont:Shadow");
|
||||
shadowLabelBMFont->setPosition( Point(size.width/2, size.height*0.4f) );
|
||||
shadowLabelBMFont->setPosition( Point(size.width/2, size.height*0.35f) );
|
||||
shadowLabelBMFont->setColor( Color3B::RED );
|
||||
shadowLabelBMFont->enableShadow(Color4B::GREEN);
|
||||
addChild(shadowLabelBMFont);
|
||||
|
@ -1354,6 +1361,7 @@ void LabelShadowTest::sliderEvent(Ref *pSender, ui::SliderEventType type)
|
|||
auto offset = Size(slider->getPercent()-50,50 - slider2->getPercent());
|
||||
shadowLabelTTF->enableShadow(Color4B::BLACK,offset);
|
||||
shadowLabelBMFont->enableShadow(Color4B::GREEN,offset);
|
||||
shadowLabelOutline->enableShadow(Color4B::BLACK,offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -374,6 +374,7 @@ public:
|
|||
|
||||
void sliderEvent(Ref *pSender, ui::SliderEventType type);
|
||||
private:
|
||||
Label* shadowLabelOutline;
|
||||
Label* shadowLabelTTF;
|
||||
Label* shadowLabelBMFont;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue