本文整理汇总了C++中CCControlButton::setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCControlButton::setPreferredSize方法的具体用法?C++ CCControlButton::setPreferredSize怎么用?C++ CCControlButton::setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCControlButton
的用法示例。
在下文中一共展示了CCControlButton::setPreferredSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
// position the label on the center of the screen
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
// add the label as a child to this layer
this->addChild(pLabel, 1);
CCRect rect1(133, 333, 42, 46);
CCScale9Sprite* btnNormal = CCScale9Sprite::create("char_bluelight.png",rect1);
CCScale9Sprite* btnDown = CCScale9Sprite::create("char_bluelight.png",rect1);
CCControlButton* controlBtn = CCControlButton::create(btnNormal);
controlBtn->setBackgroundSpriteForState(btnDown, CCControlStateSelected);
controlBtn->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
controlBtn->setPreferredSize(CCSize(60, 50));
controlBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown);
this->addChild(controlBtn);
return true;
}
示例2: createButton
CCControlButton* ButtonUtils::createButton(const char *normalFrame, const char *highLightFrame, const char *disableFrame, cocos2d::CCSize size, const char *label,float labelSize ,ccColor3B labelColor)
{
CCScale9Sprite *normal = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(normalFrame));
CCScale9Sprite *highLight = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(highLightFrame));
CCScale9Sprite *disable = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(disableFrame));
CCControlButton *btn = CCControlButton::create(label, "Arial", labelSize);
btn->setPreferredSize(size);
btn->setBackgroundSpriteForState(normal, CCControlStateNormal);
btn->setBackgroundSpriteForState(highLight, CCControlStateHighlighted);
btn->setBackgroundSpriteForState(disable, CCControlStateDisabled);
btn->setTitleColorForState(labelColor, CCControlStateNormal);
btn->setTitleColorForState(labelColor, CCControlStateHighlighted);
btn->setTitleColorForState(labelColor, CCControlStateDisabled);
btn->setTouchPriority(0);
return btn;
}
示例3: init
bool TutorialLayer::init(){
if (CCLayer::init()) {
callback = NULL;
target = NULL;
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *background = CCLayerColor::create(ccc4(0, 0, 0, 200), screenSize.width, screenSize.height);
this->addChild(background);
CCScale9Sprite *closeButtonSprite = Common::getCCScale9SpriteWithoutScale("CloseButton.png");
CCControlButton *closeButton = CCControlButton::create(closeButtonSprite);
closeButton->setPreferredSize(closeButtonSprite->getOriginalSize());
closeButton->setContentSize(closeButtonSprite->getOriginalSize());
closeButton->setPosition(ccp(screenSize.width*0.9, screenSize.height*0.9));
closeButton->addTargetWithActionForControlEvents(this, cccontrol_selector(TutorialLayer::close), CCControlEventTouchUpInside);
this->addChild(closeButton, CLOSE_BUTTON_Z);
return true;
}
return false;
}
示例4: displaySubViews
void QuestionLayer::displaySubViews()
{
CCLOG("%f %f %f %f", this->getPositionX(), this->getPositionY(), this->getContentSize().width, this->getContentSize().height);
CCArray* answer = questionObj->answerArray;
int columns = 0;
int rows = 0;
float spaceX = 0;
if (answer->count() <= 2) {
//判断题2X1个
columns = 2;
rows = 1;
spaceX = 80;
} else if (answer->count() <= 3) {
//3选1
columns = 1;
rows = 3;
spaceX = 40;
} else if (answer->count() <= 4) {
//最多2x2个答案选项的
columns = 2;
rows = (answer->count()*1.0f/columns)>(answer->count()/columns)?(answer->count()/columns+1):(answer->count()/columns);
spaceX = 60;
} else if (answer->count() <= 9) {
//最多3x3个答案选项
columns = 3;
rows = (answer->count()*1.0f/columns)>(answer->count()/columns)?(answer->count()/columns+1):(answer->count()/columns);
spaceX = 40;
} else if (answer->count() <= 16) {
//最多4x4个答案选项
columns = 4;
rows = (answer->count()*1.0f/columns)>(answer->count()/columns)?(answer->count()/columns+1):(answer->count()/columns);
spaceX = 20;
}
float spaceY = spaceX*(CCDirector::sharedDirector()->getWinSize().height/1334);
//题目标题栏高度
float topHeight = 190;
CCLOG("%f %f", this->getContentSize().width, this->getContentSize().height);
//
float totalWidth = this->getContentSize().width;
float cellWidth = (totalWidth-spaceX*(columns+1))/columns;
float totalHeight = this->getContentSize().height-topHeight-50; //要减去答题头部区域
float cellHeight = (totalHeight-spaceY*(rows+1))/rows;
CCLOG("[%d %d]:%f %f", columns, rows, cellWidth, cellHeight);
while (cellHeight > cellWidth) {
spaceY += 10;
cellHeight = (totalHeight-spaceY*(rows+1))/rows;
}
for (int i=0; i<answer->count(); i++) {
//
CCString* ans = (CCString *)(answer->objectAtIndex(i));
CCLabelTTF* pLabel = CCLabelTTF::create(ans->getCString(), "Arial", 24, CCSizeMake(cellWidth, cellHeight), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCControlButton* button = CCControlButton::create(pLabel, CCScale9Sprite::create("button_answer.png", CCRectMake(0, 0, 126, 70)));
button->addTargetWithActionForControlEvents(this, cccontrol_selector(QuestionLayer::touchDownAction), CCControlEventTouchUpInside);
button->setTag(i+1);
button->setAnchorPoint(ccp(0.5f, 0.5f));
// button->setPosition( ccp(-totalWidth/2+spaceX+(cellWidth+spaceX)*(i%columns)+cellWidth/2, -topHeight/2-totalHeight/2+spaceY+(cellHeight+spaceY)*(i/columns)+cellHeight/2) );
button->setPosition( ccp(-totalWidth/2+spaceX+(cellWidth+spaceX)*(i%columns)+cellWidth/2, (totalHeight-topHeight)/2-spaceY-(cellHeight+spaceY)*(i/columns)-cellHeight/2) );
CCLOG("button坐标:%f %f", button->getPositionX(), button->getPositionY());
button->setPreferredSize(CCSize(cellWidth, cellHeight));
this->addChild(button, 1);
}
}
示例5: init
bool QimiAlipayView::init()
{
UIMaskLayerView* mask = UIMaskLayerView::create();
this->addChild(mask);
m_pButtonList = CCArray::create();
m_pButtonList->retain();
CCSize m_size = CCDirector::sharedDirector()->getWinSize();
CCNode* container = CCNode::create();
container->setTag(100);
this->addChild(container);
container->setPosition(ccp(m_size.width/2, m_size.height/2-45));
CCNode* topCCNode = CCNode::create();
topCCNode->setPosition(ccp(m_size.width/2, m_size.height-45));
this->addChild(topCCNode);
CCSprite* bgTop = CCSprite::create("bg_top.png");
topCCNode->addChild(bgTop);
bgTop->setPosition(ccp(0, 0));
CCControlButton* backBtn = CCControlButton::create(CCScale9Sprite::create("btn_fanhui.png"));
backBtn->setPreferredSize(CCSizeMake(101, 51));
backBtn->setTouchPriority(-1000);
topCCNode->addChild(backBtn);
backBtn->setPosition(ccp(-163, 0));
backBtn->addTargetWithActionForControlEvents(this,
cccontrol_selector(QimiAlipayView::backOnClick),
CCControlEventTouchUpInside);
CCControlButton* helpBtn = CCControlButton::create(CCScale9Sprite::create("btn_bangzhu.png"));
helpBtn->setPreferredSize(CCSizeMake(93, 51));
helpBtn->setTouchPriority(-1000);
topCCNode->addChild(helpBtn);
helpBtn->setPosition(ccp(163, 0));
helpBtn->addTargetWithActionForControlEvents(this,
cccontrol_selector(QimiAlipayView::qimiHelp),
CCControlEventTouchUpInside);
CCLabelTTF* topText = CCLabelTTF::create("奇米支付中心", "Helvetica", 28);
topCCNode->addChild(topText);
topText->setColor(ccc3(104, 67, 2));
topText->setPosition(ccp(0, 0));
CCSprite* bg = CCSprite::create("bg_dabeijing_480x800.png");
bg->setPosition(ccp(0, 0));
container->addChild(bg);
////////////公共部分结束
CCRect form = CCRectMake(0, 0, 40, 40);
CCRect capInset = CCRectMake(10, 10, 10, 10);
CCScale9Sprite* scale9Sprite = CCScale9Sprite::create("bg_40x40.png", form, capInset);
scale9Sprite->setContentSize(CCSizeMake(445, 560));
scale9Sprite->setPosition(ccp(0, 12));
container->addChild(scale9Sprite);
// CCNode* containerCCNode = CCNode::create();
// container->addChild(containerCCNode);
// containerCCNode->setPosition(ccp(6, 418));
CCLabelTTF* txtTitle = CCLabelTTF::create("请选择充值金额(1元=10元宝)", "Helvetica", 26);
container->addChild(txtTitle);
txtTitle->setColor(ccc3(0, 0, 0));
txtTitle->setPosition(ccp(-204, 259));
txtTitle->setAnchorPoint(ccp(0, 0.5));
CCControlButton* m_pBtnCongzhi = CCControlButton::create(CCScale9Sprite::create("btn_querenchongzhi.png"));
m_pBtnCongzhi->setPreferredSize(CCSizeMake(248, 74));
m_pBtnCongzhi->setTouchPriority(-1000);
container->addChild(m_pBtnCongzhi);
m_pBtnCongzhi->setPosition(ccp(0, -167));
m_pBtnCongzhi->addTargetWithActionForControlEvents(this,
cccontrol_selector(QimiAlipayView::rechargeOnClick),
CCControlEventTouchUpInside);
CCLabelTTF* label10 = CCLabelTTF::create("10元", "Helvetica", 18);
label10->setColor(ccc3(0, 0, 0));
CCControlButton* m_pBtn10Select = CCControlButton::create(label10, CCScale9Sprite::create("bg_40x40.png"));
m_pBtn10Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
m_pBtn10Select->setPreferredSize(CCSizeMake(196, 47));
m_pBtn10Select->setTouchPriority(-1000);
container->addChild(m_pBtn10Select);
m_pBtn10Select->setPosition(ccp(-104, 192));
m_pBtn10Select->setTag(10);
m_pBtn10Select->addTargetWithActionForControlEvents(this,
cccontrol_selector(QimiAlipayView::selected),
CCControlEventTouchUpInside);
//.........这里部分代码省略.........
示例6: init
bool HelloWorld::init()
{
if ( !CCLayer::init())
{
return false;
}
//CCSize s = CCDirector::sharedDirector()->getWinSize();
CCNode* container = CCNode::create();
this->addChild(container);
container->setPosition(ccp(0, 80));
QimiParamInfo* paramInfo = QimiParamInfo::create(21, 15, "7a92bba4670d479c5514720c1cf46aab", "pay");
QimiPlatform::shareQimiPlatform()->setParamInfo(paramInfo);
CCControlButton* backBtn0 = CCControlButton::create(CCLabelTTF::create("全屏WEBVIEW", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn0->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn0);
backBtn0->setPosition(ccp(240, 590));
backBtn0->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::openWebURLFull),
CCControlEventTouchUpInside);
CCControlButton* backBtn = CCControlButton::create(CCLabelTTF::create("QIMI登录窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn);
backBtn->setPosition(ccp(240, 520));
backBtn->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::menuCloseCallback),
CCControlEventTouchUpInside);
CCControlButton* backBtn3 = CCControlButton::create(CCLabelTTF::create("QIMI注册窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn3->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn3);
backBtn3->setPosition(ccp(240, 450));
backBtn3->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::reg),
CCControlEventTouchUpInside);
CCControlButton* backBtn2 = CCControlButton::create(CCLabelTTF::create("QIMI直接登录窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn2->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn2);
backBtn2->setPosition(ccp(240, 380));
backBtn2->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::login),
CCControlEventTouchUpInside);
CCControlButton* backBtn7 = CCControlButton::create(CCLabelTTF::create("QIMI充值中心", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn7->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn7);
backBtn7->setPosition(ccp(240, 310));
backBtn7->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::menuCloseCallback),
CCControlEventTouchUpInside);
CCControlButton* backBtn4 = CCControlButton::create(CCLabelTTF::create("QIMI论坛", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn4->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn4);
backBtn4->setPosition(ccp(240, 240));
backBtn4->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::openWebURL),
CCControlEventTouchUpInside);
CCControlButton* backBtn5 = CCControlButton::create(CCLabelTTF::create("忘记密码", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn5->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn5);
backBtn5->setPosition(ccp(240, 160));
backBtn5->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::forget),
CCControlEventTouchUpInside);
CCControlButton* backBtn6 = CCControlButton::create(CCLabelTTF::create("退出QIMI", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn6->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn6);
backBtn6->setPosition(ccp(240, 90));
backBtn6->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::quit),
CCControlEventTouchUpInside);
CCControlButton* backBtn9 = CCControlButton::create(CCLabelTTF::create("获取设备ID", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
backBtn9->setPreferredSize(CCSizeMake(200, 50));
container->addChild(backBtn9);
backBtn9->setPosition(ccp(240, 20));
backBtn9->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::getDivceId),
CCControlEventTouchUpInside);
return true;
}
示例7: init
bool ControllerScene::init(){
CCMenu *menu = CCMenu::create();
menu->setPosition(CCPointZero);
this->addChild(menu);
CCLabelTTF *label = CCLabelTTF::create("CCTextFieldTTF", "Arial", 24);
CCMenuItemLabel *item = CCMenuItemLabel::create(label, this, menu_selector(ControllerScene::menuItemClick1));
item->setPosition(ccp(320, 1100));
menu->addChild(item);
label = CCLabelTTF::create("确定", "Arial", 24);
m_btn = CCMenuItemLabel::create(label, this, menu_selector(ControllerScene::btnOk));
m_btn->setPosition(ccp(400, 1050));
menu->addChild(m_btn);
m_texField = CCTextFieldTTF::textFieldWithPlaceHolder("input", CCSizeMake(200, 50), kCCTextAlignmentLeft, "Arial", 24);
m_texField->setPosition(ccp(320, 1050));
this->addChild(m_texField);
m_texField->attachWithIME();
m_name = CCLabelTTF::create("show info", "Arial", 24);
m_name->setPosition(ccp(100, 1100));
this->addChild(m_name);
//CCControlButton label+s9
label = CCLabelTTF::create("BUTTON", "Arial", 24);
CCControlButton *btn = CCControlButton::create(label , CCScale9Sprite::create("start.png"));
btn->setPreferredSize(CCSizeMake(228, 81));
btn->setLabelAnchorPoint(ccp(0.5, 2));
btn->setPosition(ccp(320, 1000));
this->addChild(btn);
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(ControllerScene::btnClick), CCControlEventTouchDown);
//CCControlButton s9
CCScale9Sprite *s9 = CCScale9Sprite::create("start.png");
btn = CCControlButton::create(s9);
btn->setPosition(ccp(320, 900));
btn->setPreferredSize(CCSizeMake(228, 81));
this->addChild(btn);
//CCControlButton title
btn = CCControlButton::create("CCControlButton", "Arial", 24);
btn->setPosition(ccp(320, 800));
this->addChild(btn);
//s9
// s9 = CCScale9Sprite::create("home.png");
// s9->setPosition(ccp(100, 800));
// this->addChild(s9);
//CCControlColourPicker not useful
CCControlColourPicker *cp = CCControlColourPicker::create();
cp->setPosition(ccp(320, 750));
this->addChild(cp);
//CCControlPotentiometer
CCControlPotentiometer *pot = CCControlPotentiometer::create("potentiometerTrack.png", "potentiometerProgress.png", "potentiometerButton.png");
pot->setPosition(ccp(100, 750));
this->addChild(pot);
pot->setValue(90);
//CCControlSlider
CCControlSlider *slider = CCControlSlider::create("sliderTrack.png", "sliderProgress.png", "sliderThumb.png");
slider->setPosition(ccp(150, 600));
slider->setMinimumValue(0);
slider->setMaximumValue(100);
this->addChild(slider);
slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControllerScene::valueChanged), CCControlEventValueChanged);
//CCControlStepper
CCControlStepper *ste = CCControlStepper::create(CCSprite::create("stepper-minus.png"), CCSprite::create("stepper-plus.png"));
ste->setPosition(ccp(320, 600));
this->addChild(ste);
//CCControlSwitch
CCControlSwitch *swi = CCControlSwitch::create(CCSprite::create("switch-mask.png"), CCSprite::create("switch-on.png"), CCSprite::create("switch-off.png"), CCSprite::create("switch-thumb.png"), CCLabelTTF::create("on", "Arial", 24), CCLabelTTF::create("off", "Arial", 24));
swi->setPosition(ccp(500, 600));
this->addChild(swi);
//
CCEditBox *edi = CCEditBox::create(CCSizeMake(200, 50), CCScale9Sprite::create("start.png"));
edi->setPosition(ccp(150, 500));
this->addChild(edi);
return true;
}
示例8: initWithGift
bool MailWritePopUpView::initWithGift(int giftID,int propID) {
if(!PopupBaseView::init()) {
return false;
}
setIsHDPanel(true);
mPropID = propID;
mType = 1;
// auto cf = CCLoadSprite::getSF("Mail_diban.png");
auto cf = CCLoadSprite::getSF("Mail_BG1.png");
if (cf==NULL) {
CCLoadSprite::doResourceByCommonIndex(11, true);
CCLoadSprite::doResourceByCommonIndex(6, true);
setCleanFunction([]() {
CCLoadSprite::doResourceByCommonIndex(11, false);
CCLoadSprite::doResourceByCommonIndex(6, false);
});
}
else {
CCLoadSprite::doResourceByCommonIndex(11, true);
setCleanFunction([]() {
CCLoadSprite::doResourceByCommonIndex(11, false);
});
}
auto bg = CCBLoadFile("NEWMailWriteView", this, this);
if (CCCommonUtils::isIosAndroidPad()) {
this->setContentSize(CCDirector::sharedDirector()->getWinSize());
}
else
this->setContentSize(bg->getContentSize());
// setTitleName(_lang("105513"));
m_titleText->setString(_lang("105513"));
if (CCCommonUtils::isIosAndroidPad()) {
int extH = getExtendHeight();
this->m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + extH));
m_downNode->setPositionY(m_downNode->getPositionY() - extH);
m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
// m_nodeContent->setPositionY(m_nodeContent->getPositionY() - extH);
auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
picBg1->setAnchorPoint(ccp(0, 0));
picBg1->setPosition(ccp(0, 0));
picBg1->setScaleX(2.4);
tBatchNode->addChild(picBg1);
int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
int curHeight = picBg1->getContentSize().height;
while(curHeight < maxHeight)
{
auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
picBg2->setAnchorPoint(ccp(0, 0));
picBg2->setPosition(ccp(0, curHeight));
picBg2->setScaleX(2.4);
tBatchNode->addChild(picBg2);
curHeight += picBg2->getContentSize().height;
}
m_bgNode->addChild(tBatchNode);
}
else {
int extH = getExtendHeight();
this->m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + extH));
m_downNode->setPositionY(m_downNode->getPositionY() - extH);
m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
// m_nodeContent->setPositionY(m_nodeContent->getPositionY() - extH);
auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
picBg1->setAnchorPoint(ccp(0, 0));
picBg1->setPosition(ccp(0, 0));
tBatchNode->addChild(picBg1);
int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
int curHeight = picBg1->getContentSize().height;
while(curHeight < maxHeight)
{
auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
picBg2->setAnchorPoint(ccp(0, 0));
picBg2->setPosition(ccp(0, curHeight));
tBatchNode->addChild(picBg2);
curHeight += picBg2->getContentSize().height;
}
m_bgNode->addChild(tBatchNode);
}
// CCSize wNodeSize = this->m_waitingNode->getContentSize();
// m_waitingNode->setContentSize(CCSize(wNodeSize.width,wNodeSize.height + dh));
// m_waitingNode->setPositionY(m_waitingNode->getPositionY() - dh*0.5);
// this->m_nameText->setString(_lang("105505").c_str());
// this->m_titleText->setString(_lang("105503").c_str());
// this->m_contentText->setString(_lang("105504").c_str());
CCNode *searchnode = CCNode::create();
auto spr1 = CCLoadSprite::createScale9Sprite("button_dark.png");
CCControlButton *shareBtn = CCControlButton::create(spr1);
searchnode->addChild(shareBtn);
shareBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(MailWritePopUpView::onChooseName), CCControlEventTouchUpInside);
CCSprite* sprIcon = CCLoadSprite::createSprite("search_icon.png");
CCSize sprSize = sprIcon->getContentSize();
searchnode->addChild(sprIcon);
CCCommonUtils::setSpriteMaxSize(sprIcon, 40);
shareBtn->setPreferredSize(CCSize(60, 60));
//.........这里部分代码省略.........
示例9: init
bool CCLobbyView::init( CCNetworkLogic* network, const CCSize& mySize )
{
if( CCLayer::init() )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
const CCPoint& center = ccpMult( ccpFromSize( mySize ), 0.5f );
CCPoint position = CCPointZero;
CCSize size = CCSizeZero;
int length = 0;
int fontSize = 0;
this->setNetwork( network );
CCSprite* s = CCSprite::create("Images/r1.png");
s->retain();
CCRect rect = CCRectZero;
rect.size = s->getContentSize();
s->release();
fontSize = 12;
CCLabelTTF* label = CCLabelTTF::create( "Connect", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
CCScale9Sprite* sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
CCControlButton* button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::connectButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x -= 100;
button->setPosition( position );
this->setConnectButton( button );
label = CCLabelTTF::create( "Create Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::createGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
//position.x += 0;
button->setPosition( position );
this->setCreateGameButton( button );
label = CCLabelTTF::create( "Random Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.6f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::joinGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x += 100;
button->setPosition( position );
this->setRandomGameButton( button );
this->_lobbyViewDataSource = new CCLobbyViewDataSource( this );
fontSize = 16;
length = mySize.width;
size = this->_lobbyViewDataSource->cellSizeForTable( NULL );
size.height *= 3;
CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, size );
table->setContentOffset( CCPointZero );
table->setDirection(kCCScrollViewDirectionVertical);
position = center;
position.x -= size.width * 0.5f;
position.y -= fontSize + ( size.height * 0.17f );
table->setPosition( position );
table->setDelegate( this );
table->setVerticalFillOrder(kCCTableViewFillTopDown);
this->setRoomTable( table );
table->reloadData();
fontSize = 16;
label = CCLabelTTF::create("Running games:", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
position = center;
position.x -= size.width * 0.4f;
position.y += size.height - ( fontSize * 0.5f );
label->setPosition( position );
//label->setAnchorPoint( CCPointZero );
this->setRoomTableLabel( label );
fontSize = 16;
CCLabelTTF* console = CCLabelTTF::create("disconnected", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
console->setColor( ccc3(255, 255, 255) );
console->setContentSize(winSize);
position = center;
position.y += 100;
console->setPosition( position );
//.........这里部分代码省略.........