本文整理汇总了C++中ControlButton::setAdjustBackgroundImage方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlButton::setAdjustBackgroundImage方法的具体用法?C++ ControlButton::setAdjustBackgroundImage怎么用?C++ ControlButton::setAdjustBackgroundImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlButton
的用法示例。
在下文中一共展示了ControlButton::setAdjustBackgroundImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool ControlButtonTest_Styling::init()
{
if (ControlScene::init())
{
auto screenSize = Director::getInstance()->getWinSize();
auto layer = Node::create();
addChild(layer, 1);
int space = 10; // px
double max_w = 0, max_h = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
// Add the buttons
ControlButton *button = standardButtonWithTitle(StringUtils::format("%d",rand() % 30).c_str());
button->setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust
// It'll use the prefered size of the background image
button->setPosition(button->getContentSize().width / 2 + (button->getContentSize().width + space) * i,
button->getContentSize().height / 2 + (button->getContentSize().height + space) * j);
layer->addChild(button);
max_w = MAX(button->getContentSize().width * (i + 1) + space * i, max_w);
max_h = MAX(button->getContentSize().height * (j + 1) + space * j, max_h);
}
}
layer->setAnchorPoint(Vec2(0.5, 0.5));
layer->setContentSize(Size(max_w, max_h));
layer->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
// Add the black background
auto backgroundButton = ui::Scale9Sprite::create("extensions/buttonBackground.png");
backgroundButton->setContentSize(Size(max_w + 14, max_h + 14));
backgroundButton->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
addChild(backgroundButton);
return true;
}
return false;
}