本文整理汇总了C++中CCControlButton::setMargins方法的典型用法代码示例。如果您正苦于以下问题:C++ CCControlButton::setMargins方法的具体用法?C++ CCControlButton::setMargins怎么用?C++ CCControlButton::setMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCControlButton
的用法示例。
在下文中一共展示了CCControlButton::setMargins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool HelloScene::init()
{
if (!CCLayer::init())
{
return false;
}
CCSprite *bg = CCSprite::create("background.png");
bg->setPosition(VisibleRect::center());
//CCSize &winSize = CCDirector::sharedDirector()->getWinSize();
//float scalex = winSize.width / 480;
//float scaley = winSize.height / 800;
//bg->setScaleX(scalex);
//bg->setScaleY(scaley);
addChild(bg);
const CCPoint ¢er = VisibleRect::center();
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloScene::menuCloseCallback));
pCloseItem->setPosition(ccp(VisibleRect::rightBottom().x - pCloseItem->getContentSize().width/2 ,
pCloseItem->getContentSize().height/2));
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
CCLabelTTF *title = CCLabelTTF::create("Lovexin Plane Chess", "Arial", 40);
title->setPosition(ccp(center.x, center.y + 250));
CCLabelTTF *author = CCLabelTTF::create("made by Waltz Duyf", "Arial", 20);
author->setPosition(ccp(center.x + 100, center.y + 200));
addChild(title);
addChild(author);
addSetupSwitch(ccp(center.x - 120, center.y + 50 ), "RED", ccc3(255, 0, 0), FORCE_COLOR_RED);//, cccontrol_selector(HelloScene::valueChangedJoinInR), cccontrol_selector(HelloScene::valueChangedAIR));
addSetupSwitch(ccp(center.x - 120, center.y - 10 ), "YEL", ccc3(234, 165, 0), FORCE_COLOR_YELLOW);//, cccontrol_selector(HelloScene::valueChangedJoinInY), cccontrol_selector(HelloScene::valueChangedAIY));
addSetupSwitch(ccp(center.x - 120, center.y - 70 ), "GRE", ccc3(0, 255, 0), FORCE_COLOR_GREEN);//, cccontrol_selector(HelloScene::valueChangedJoinInG), cccontrol_selector(HelloScene::valueChangedAIG));
addSetupSwitch(ccp(center.x - 120, center.y - 130), "BLU", ccc3(0, 144, 255), FORCE_COLOR_BLUE);//, cccontrol_selector(HelloScene::valueChangedJoinInB), cccontrol_selector(HelloScene::valueChangedAIB));
CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
CCLabelTTF *titleButton = CCLabelTTF::create("Play Now", "Arial", 30);
titleButton->setColor(ccc3(159, 168, 176));
CCControlButton *button = CCControlButton::create(titleButton, backgroundButton);
button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
button->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
button->setMargins(70, 20);
button->setPosition(ccp(center.x, center.y - 250));
addChild(button);
button->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloScene::playBtnCallback), CCControlEventTouchUpInside);
return true;
}