本文整理汇总了C++中ControlButton::setOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlButton::setOpacity方法的具体用法?C++ ControlButton::setOpacity怎么用?C++ ControlButton::setOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlButton
的用法示例。
在下文中一共展示了ControlButton::setOpacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool ControlButtonTest_HelloVariableSize::init()
{
if (ControlScene::init())
{
auto screenSize = Director::getInstance()->getWinSize();
// Defines an array of title to create buttons dynamically
std::vector<std::string> vec;
vec.push_back("Hello");
vec.push_back("Variable");
vec.push_back("Size");
vec.push_back("!");
auto layer = Node::create();
addChild(layer, 1);
double total_width = 0, height = 0;
int i = 0;
for (auto& title : vec)
{
// Creates a button with this string as title
ControlButton *button = standardButtonWithTitle(title.c_str());
if (i == 0)
{
button->setOpacity(50);
button->setColor(Color3B(0, 255, 0));
}
else if (i == 1)
{
button->setOpacity(200);
button->setColor(Color3B(0, 255, 0));
}
else if (i == 2)
{
button->setOpacity(100);
button->setColor(Color3B(0, 0, 255));
}
button->setPosition(total_width + button->getContentSize().width / 2, button->getContentSize().height / 2);
layer->addChild(button);
// Compute the size of the layer
height = button->getContentSize().height;
total_width += button->getContentSize().width;
i++;
}
layer->setAnchorPoint(Vec2 (0.5, 0.5));
layer->setContentSize(Size(total_width, height));
layer->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
// Add the black background
auto background = ui::Scale9Sprite::create("extensions/buttonBackground.png");
background->setContentSize(Size(total_width + 14, height + 14));
background->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f);
addChild(background);
return true;
}
return false;
}