本文整理汇总了C++中CCControlButton::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CCControlButton::setColor方法的具体用法?C++ CCControlButton::setColor怎么用?C++ CCControlButton::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCControlButton
的用法示例。
在下文中一共展示了CCControlButton::setColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool CCControlButtonTest_HelloVariableSize::init()
{
if (CCControlScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
// Defines an array of title to create buttons dynamically
CCArray *stringArray = CCArray::create(
ccs("Hello"),
ccs("Variable"),
ccs("Size"),
ccs("!"),
NULL);
CCNode *layer = CCNode::create();
addChild(layer, 1);
double total_width = 0, height = 0;
// For each title in the array
CCObject* pObj = NULL;
int i = 0;
CCARRAY_FOREACH(stringArray, pObj)
{
CCString* title = (CCString*)pObj;
// Creates a button with this string as title
CCControlButton *button = standardButtonWithTitle(title->getCString());
if (i == 0)
{
button->setOpacity(50);
button->setColor(ccc3(0, 255, 0));
}
else if (i == 1)
{
button->setOpacity(200);
button->setColor(ccc3(0, 255, 0));
}
else if (i == 2)
{
button->setOpacity(100);
button->setColor(ccc3(0, 0, 255));
}
button->setPosition(ccp (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(ccp (0.5, 0.5));
layer->setContentSize(CCSizeMake(total_width, height));
layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
// Add the black background
CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png");
background->setContentSize(CCSizeMake(total_width + 14, height + 14));
background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(background);
return true;
}