diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 39aaa8860c..980ed7a8c2 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1226,6 +1226,15 @@ void Label::computeStringNumLines() _currNumLines = quantityOfLines; } +int Label::getStringNumLines() const { + if (_contentDirty) + { + const_cast(this)->updateContent(); + } + + return _currNumLines; +} + int Label::getStringLength() const { return static_cast(_currentUTF16String.length()); diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index c41f5c0da8..59e9288ab6 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -235,7 +235,7 @@ public: float getAdditionalKerning() const; // string related stuff - int getStringNumLines() const { return _currNumLines;} + int getStringNumLines() const; int getStringLength() const; FontAtlas* getFontAtlas() { return _fontAtlas; }