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;
|
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)
|
if (dim.width != m_tDimensions.width || dim.height != m_tDimensions.height)
|
||||||
{
|
{
|
||||||
|
@ -278,21 +278,16 @@ void CCLabelTTF::setFontName(const char *fontName)
|
||||||
void CCLabelTTF::updateTexture()
|
void CCLabelTTF::updateTexture()
|
||||||
{
|
{
|
||||||
CCTexture2D *tex;
|
CCTexture2D *tex;
|
||||||
if (m_tDimensions.width == 0 || m_tDimensions.height == 0)
|
|
||||||
{
|
// let system compute label's width or height when its value is 0
|
||||||
tex = new CCTexture2D();
|
// refer to cocos2d-x issue #1430
|
||||||
tex->initWithString(m_string.c_str(), m_pFontName->c_str(), m_fFontSize * CC_CONTENT_SCALE_FACTOR()) ;
|
tex = new CCTexture2D();
|
||||||
}
|
tex->initWithString(m_string.c_str(),
|
||||||
else
|
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
|
||||||
{
|
m_hAlignment,
|
||||||
tex = new CCTexture2D();
|
m_vAlignment,
|
||||||
tex->initWithString(m_string.c_str(),
|
m_pFontName->c_str(),
|
||||||
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
|
m_fFontSize * CC_CONTENT_SCALE_FACTOR());
|
||||||
m_hAlignment,
|
|
||||||
m_vAlignment,
|
|
||||||
m_pFontName->c_str(),
|
|
||||||
m_fFontSize * CC_CONTENT_SCALE_FACTOR());
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setTexture(tex);
|
this->setTexture(tex);
|
||||||
tex->release();
|
tex->release();
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment);
|
void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment);
|
||||||
|
|
||||||
CCSize getDimensions();
|
CCSize getDimensions();
|
||||||
void setDimensions(CCSize &dim);
|
void setDimensions(const CCSize &dim);
|
||||||
|
|
||||||
float getFontSize();
|
float getFontSize();
|
||||||
void setFontSize(float fontSize);
|
void setFontSize(float fontSize);
|
||||||
|
|
Loading…
Reference in New Issue