cocos2d-x button setTitleLabel
string file("res/Button.png"); auto btn = cocos2d::ui::Button::create(file, file, file); btn->setColor(Color3B(24, 48, 64)); btn->setPosition(display / 2); btn->setPressedActionEnabled(true); btn->setContentSize(Size(200, 100)); btn->setTitleLabel(Label::createWithTTF("","fonts/arial.ttf",30)); btn->setTitleColor(Color3B::BLUE); btn->setTitleText("Musics"); btn->setTitleFontSize(30); btn->setName("Music"); btn->addClickEventListener(std::bind(&FirstScene::OnCallback, this, std::placeholders::_1)); this->addChild(btn);
//需要在设置title之前改变节点