mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1183 from minggo/iss1430_label
compute correct label's width or height when its value is 0
This commit is contained in:
commit
f8c9ca5286
|
@ -221,7 +221,7 @@ CCSize CCLabelTTF::getDimensions()
|
|||
return m_tDimensions;
|
||||
}
|
||||
|
||||
void CCLabelTTF::setDimensions(CCSize &dim)
|
||||
void CCLabelTTF::setDimensions(const CCSize &dim)
|
||||
{
|
||||
if (dim.width != m_tDimensions.width || dim.height != m_tDimensions.height)
|
||||
{
|
||||
|
@ -278,13 +278,9 @@ void CCLabelTTF::setFontName(const char *fontName)
|
|||
void CCLabelTTF::updateTexture()
|
||||
{
|
||||
CCTexture2D *tex;
|
||||
if (m_tDimensions.width == 0 || m_tDimensions.height == 0)
|
||||
{
|
||||
tex = new CCTexture2D();
|
||||
tex->initWithString(m_string.c_str(), m_pFontName->c_str(), m_fFontSize * CC_CONTENT_SCALE_FACTOR()) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// let system compute label's width or height when its value is 0
|
||||
// refer to cocos2d-x issue #1430
|
||||
tex = new CCTexture2D();
|
||||
tex->initWithString(m_string.c_str(),
|
||||
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
|
||||
|
@ -292,7 +288,6 @@ void CCLabelTTF::updateTexture()
|
|||
m_vAlignment,
|
||||
m_pFontName->c_str(),
|
||||
m_fFontSize * CC_CONTENT_SCALE_FACTOR());
|
||||
}
|
||||
|
||||
this->setTexture(tex);
|
||||
tex->release();
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment);
|
||||
|
||||
CCSize getDimensions();
|
||||
void setDimensions(CCSize &dim);
|
||||
void setDimensions(const CCSize &dim);
|
||||
|
||||
float getFontSize();
|
||||
void setFontSize(float fontSize);
|
||||
|
|
Loading…
Reference in New Issue