diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 9d20454783..d1a033b578 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1273,7 +1273,7 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare { updateContent(); } - + uint32_t flags = processParentFlags(parentTransform, parentFlags); if (!_originalUTF8String.empty() && _shadowEnabled && (_shadowDirty || (flags & FLAGS_DIRTY_MASK))) @@ -1318,9 +1318,8 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare else break; } - // self draw - if (visibleByCamera) - this->drawSelf(renderer, flags); + + this->drawSelf(visibleByCamera, renderer, flags); for (auto it = _children.cbegin() + i; it != _children.cend(); ++it) { @@ -1328,15 +1327,15 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare } } - else if (visibleByCamera) + else { - this->drawSelf(renderer, flags); + this->drawSelf(visibleByCamera, renderer, flags); } _director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void Label::drawSelf(Renderer* renderer, uint32_t flags) +void Label::drawSelf(bool visibleByCamera, Renderer* renderer, uint32_t flags) { if (_textSprite) { @@ -1346,7 +1345,7 @@ void Label::drawSelf(Renderer* renderer, uint32_t flags) } _textSprite->visit(renderer, _modelViewTransform, flags); } - else + else if (visibleByCamera) { draw(renderer, _modelViewTransform, flags); } diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index f7389f55ab..39a6fa0f9b 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -512,7 +512,7 @@ protected: void onDraw(const Mat4& transform, bool transformUpdated); void onDrawShadow(GLProgram* glProgram); - void drawSelf(Renderer* renderer, uint32_t flags); + void drawSelf(bool visibleByCamera, Renderer* renderer, uint32_t flags); virtual void alignText(); bool computeHorizontalKernings(const std::u16string& stringToRender);