本文整理汇总了C++中ControlButton::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlButton::addChild方法的具体用法?C++ ControlButton::addChild怎么用?C++ ControlButton::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlButton
的用法示例。
在下文中一共展示了ControlButton::addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: standardButtonWithTitle
ControlButton* standardButtonWithTitle( const char * bgname, const char * bgseledname, const char * title){
//Creates and return a button with a default background and title color.
// Scale9Sprite *backgroundButton = Scale9Sprite::create(bgname);//按下前
// Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create(bgseledname);//按下后
ControlButton* btn = ControlButton::create();
btn->setPreferredSize(Size(522, 88));
Scale9Sprite* normal = Scale9Sprite::create(bgname);
Scale9Sprite* select = Scale9Sprite::create(bgseledname);
Scale9Sprite* hightlight = Scale9Sprite::create(bgseledname);
Scale9Sprite* disable = Scale9Sprite::create(bgname);
btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
btn->setBackgroundSpriteForState(select, Control::State::SELECTED);
btn->setBackgroundSpriteForState(hightlight, Control::State::HIGH_LIGHTED);
btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
LabelTTF *titleButton = LabelTTF::create(title, "AmericanTypewriter", 30);//添加文字
titleButton->setAnchorPoint(Point(0.5f, 0.5f));
titleButton->setPosition(Point(btn->getContentSize().width/2, btn->getContentSize().height/2));
titleButton->setColor(Color3B::BLACK);//设置文字点击前的颜色
titleButton->setTag(1000);
btn->addChild(titleButton);
return btn;
}