mirror of https://github.com/axmolengine/axmol.git
Added default init method for CCLabelTTF (See: 24125b93aad2d4fc7ebf1bc6e4ef6b8b83ff770d).
This commit is contained in:
parent
827ee160b5
commit
9ca7fa468a
|
@ -52,6 +52,20 @@ CCLabelTTF::~CCLabelTTF()
|
|||
CC_SAFE_DELETE(m_pString);
|
||||
}
|
||||
|
||||
CCLabelTTF * CCLabelTTF::node()
|
||||
{
|
||||
CCLabelTTF * pRet = new CCLabelTTF();
|
||||
if (pRet && pRet->init())
|
||||
{
|
||||
pRet->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(pRet);
|
||||
}
|
||||
return pRet;
|
||||
}
|
||||
|
||||
CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
|
||||
{
|
||||
CCLabelTTF *pRet = new CCLabelTTF();
|
||||
|
@ -119,6 +133,34 @@ bool CCLabelTTF::initWithString(const char *label, const char *fontName, float f
|
|||
}
|
||||
return false;
|
||||
}
|
||||
void CCLabelTTF::setFontName(const char *fontName)
|
||||
{
|
||||
if(this->m_pFontName == NULL || strcmp(this->m_pFontName->c_str(), fontName))
|
||||
{
|
||||
CC_SAFE_DELETE(m_pFontName);
|
||||
this->m_pFontName = new std::string(fontName);
|
||||
|
||||
this->setString(this->m_pString->c_str());
|
||||
}
|
||||
}
|
||||
void CCLabelTTF::setFontSize(float fontSize)
|
||||
{
|
||||
if(this->m_fFontSize != fontSize)
|
||||
{
|
||||
this->m_fFontSize = fontSize;
|
||||
|
||||
this->setString(this->m_pString->c_str());
|
||||
}
|
||||
}
|
||||
void CCLabelTTF::setHorizontalAlignment(CCTextAlignment pCCTextAlignment)
|
||||
{
|
||||
if(this->m_eAlignment != pCCTextAlignment)
|
||||
{
|
||||
this->m_eAlignment = pCCTextAlignment;
|
||||
|
||||
this->setString(this->m_pString->c_str());
|
||||
}
|
||||
}
|
||||
void CCLabelTTF::setString(const char *label)
|
||||
{
|
||||
if (m_pString)
|
||||
|
|
|
@ -52,11 +52,18 @@ public:
|
|||
bool initWithString(const char *label, const char *fontName, float fontSize);
|
||||
/** initializes the CCLabelTTF */
|
||||
bool init();
|
||||
/** Creates an label.
|
||||
*/
|
||||
static CCLabelTTF * node();
|
||||
/** changes the string to render
|
||||
* @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas
|
||||
*/
|
||||
virtual void setString(const char *label);
|
||||
virtual const char* getString(void);
|
||||
virtual void setFontName(const char *fontName);
|
||||
virtual void setFontSize(float fontSize);
|
||||
virtual void setHorizontalAlignment(CCTextAlignment);
|
||||
// virtual void setVerticalAlignment(...); // ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b )
|
||||
|
||||
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue