Merge pull request #13456 from WenhaiLin/v3.8-label-globalZOrder

Fixed `Label::setGlobalZOrder ` is invalid if label create with system font.
This commit is contained in:
子龙山人 2015-08-19 13:46:00 +08:00
commit 4f9a81198b
2 changed files with 16 additions and 0 deletions

View File

@ -983,6 +983,7 @@ void Label::createSpriteForSystemFont(const FontDefinition& fontDef)
_textSprite = Sprite::createWithTexture(texture); _textSprite = Sprite::createWithTexture(texture);
//set camera mask using label's camera mask, because _textSprite may be null when setting camera mask to label //set camera mask using label's camera mask, because _textSprite may be null when setting camera mask to label
_textSprite->setCameraMask(getCameraMask()); _textSprite->setCameraMask(getCameraMask());
_textSprite->setGlobalZOrder(getGlobalZOrder());
_textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->setContentSize(_textSprite->getContentSize()); this->setContentSize(_textSprite->getContentSize());
texture->release(); texture->release();
@ -1027,6 +1028,7 @@ void Label::createShadowSpriteForSystemFont(const FontDefinition& fontDef)
_shadowNode->setBlendFunc(_blendFunc); _shadowNode->setBlendFunc(_blendFunc);
} }
_shadowNode->setCameraMask(getCameraMask()); _shadowNode->setCameraMask(getCameraMask());
_shadowNode->setGlobalZOrder(getGlobalZOrder());
_shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
@ -1724,4 +1726,17 @@ FontDefinition Label::_getFontDefinition() const
return systemFontDef; return systemFontDef;
} }
void Label::setGlobalZOrder(float globalZOrder)
{
Node::setGlobalZOrder(globalZOrder);
if (_textSprite)
{
_textSprite->setGlobalZOrder(globalZOrder);
if (_shadowNode)
{
_shadowNode->setGlobalZOrder(globalZOrder);
}
}
}
NS_CC_END NS_CC_END

View File

@ -453,6 +453,7 @@ public:
virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void removeChild(Node* child, bool cleanup = true) override; virtual void removeChild(Node* child, bool cleanup = true) override;
virtual void setGlobalZOrder(float globalZOrder) override;
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize, CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT, const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,