issue #4636, finish UITextBMFont

This commit is contained in:
andyque 2014-04-03 15:45:06 +08:00
parent 08bf6c27f4
commit ed2c38eb98
2 changed files with 4 additions and 9 deletions

View File

@ -88,7 +88,7 @@ void TextBMFont::setFntFile(const std::string& fileName)
updateAnchorPoint(); updateAnchorPoint();
labelBMFontScaleChangedWithSize(); labelBMFontScaleChangedWithSize();
_fntFileHasInit = true; _fntFileHasInit = true;
setText(_stringValue.c_str()); setText(_stringValue);
} }
void TextBMFont::setText(const std::string& value) void TextBMFont::setText(const std::string& value)
@ -181,8 +181,8 @@ void TextBMFont::copySpecialProperties(Widget *widget)
TextBMFont* labelBMFont = dynamic_cast<TextBMFont*>(widget); TextBMFont* labelBMFont = dynamic_cast<TextBMFont*>(widget);
if (labelBMFont) if (labelBMFont)
{ {
setFntFile(labelBMFont->_fntFileName.c_str()); setFntFile(labelBMFont->_fntFileName);
setText(labelBMFont->_stringValue.c_str()); setText(labelBMFont->_stringValue);
} }
} }

View File

@ -11,18 +11,13 @@ bool UITextBMFontTest::init()
{ {
Size widgetSize = _widget->getSize(); Size widgetSize = _widget->getSize();
Text* alert = Text::create(); Text* alert = Text::create("TextBMFont","TextBMFont",30);
alert->setText("TextBMFont");
alert->setFontName("fonts/Marker Felt.ttf");
alert->setFontSize(30);
alert->setColor(Color3B(159, 168, 176)); alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
_uiLayer->addChild(alert); _uiLayer->addChild(alert);
// Create the TextBMFont // Create the TextBMFont
TextBMFont* textBMFont = TextBMFont::create("BMFont", "cocosui/bitmapFontTest2.fnt"); TextBMFont* textBMFont = TextBMFont::create("BMFont", "cocosui/bitmapFontTest2.fnt");
// textBMFont->setFntFile("cocosui/bitmapFontTest2.fnt");
// textBMFont->setText("BMFont");
textBMFont->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f)); textBMFont->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f));
_uiLayer->addChild(textBMFont); _uiLayer->addChild(textBMFont);