本文整理汇总了C++中ControlButton::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlButton::setContentSize方法的具体用法?C++ ControlButton::setContentSize怎么用?C++ ControlButton::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlButton
的用法示例。
在下文中一共展示了ControlButton::setContentSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ControlButton *TDDSubMenu::createButton(const std::string &name, int tag,
const Point &pos, const Size &size)
{
Color3B colorNormal = Color3B::WHITE;
//Color3B colorSelected = colorNormal;
Scale9Sprite *bgButton = Scale9Sprite::create();
Scale9Sprite *bgHiliButton = Scale9Sprite::create();
// bgButton->setContentSize(Size(200, 50));
Label *titleButton = Label::createWithSystemFont(name.c_str(), "Arial", 15);
titleButton->setColor(colorNormal);
ControlButton *button = ControlButton::create(titleButton, bgButton);
button->setBackgroundSpriteForState(bgHiliButton, Control::State::HIGH_LIGHTED);
TDDHelper::setAlphaPremultiplied(button);
button->setTag(tag);
button->setContentSize(size);
button->setPosition(pos);
button->setSelected(false);
return button;
}
示例2: init
bool LoginScene::init()
{
if (!Layer::init())
return false;
Size winSize = Director::getInstance()->getWinSize();
auto pBckSprite = Scale9Sprite::create("green_edit.png");
addChild(pBckSprite);
pBckSprite->setPosition(Vec2(winSize.width / 2, winSize.height / 2 + 25));
pBckSprite->setContentSize(Size(winSize.width / 2, 35));
m_txtUserName = ui::TextField::create(StringResUtil::instance()->getStringForKey("username"), "Arial",30);
m_txtUserName->setPlaceHolderColor(Color4B::WHITE);
m_txtUserName->setTextColor(Color4B::WHITE);
addChild(m_txtUserName);
m_txtUserName->setPosition(Vec2(winSize.width / 2, winSize.height / 2 + 25));
auto pPwdBckSprite = Scale9Sprite::create("green_edit.png");
addChild(pPwdBckSprite);
pPwdBckSprite->setPosition(Vec2(winSize.width / 2, winSize.height / 2 - 25));
pPwdBckSprite->setContentSize(Size(winSize.width / 2, 35));
m_txtPassword = ui::TextField::create(StringResUtil::instance()->getStringForKey("password"), "Arial",30);
m_txtPassword->setPlaceHolderColor(Color4B::WHITE);
m_txtPassword->setTextColor(Color4B::WHITE);
m_txtPassword->setPasswordEnabled(true);
addChild(m_txtPassword);
m_txtPassword->setPosition(Vec2(winSize.width / 2, winSize.height / 2 - 25));
/*auto starMenuItem = MenuItemImage::create(
"button.png",
"button.png", CC_CALLBACK_1(LoginScene::starMenuCallback, this));
starMenuItem->setPosition(Point::ZERO);
starMenuItem->setContentSize(Size(80, 30));
auto starMenu = Menu::create(starMenuItem, NULL);
starMenu->setPosition(Point(winSize.width / 2, winSize.height / 2 - 80));
this->addChild(starMenu, 1);*/
LabelTTF *label = LabelTTF::create("login", "Marker Felt", 30);
Scale9Sprite *normalBck = Scale9Sprite::create("button.png");
ControlButton *button = ControlButton::create(label, normalBck);
button->setContentSize(Size(80, 30));
button->setPosition(Point(winSize.width / 2, winSize.height / 2 - 80));
button->addTargetWithActionForControlEvents(this, cccontrol_selector(LoginScene::touchDown), Control::EventType::TOUCH_DOWN);
addChild(button);
return true;
}