本文整理汇总了C++中CCControlButton::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCControlButton::setPosition方法的具体用法?C++ CCControlButton::setPosition怎么用?C++ CCControlButton::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCControlButton
的用法示例。
在下文中一共展示了CCControlButton::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GeneralDialogTest::init()
{
if (CCLayer::init())
{
//正常状态按钮
CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
//按下效果
CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
//按钮的大小根据标题变化
CCLabelTTF *titleButton = CCLabelTTF::create("Touch Me!", "Marker Felt", 30);
//按钮颜色
titleButton->setColor(ccc3(159, 168, 176));
CCControlButton* controlButton = CCControlButton::create(titleButton, backgroundButton);
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
// controlButton->setAnchorPoint(ccp(0.5f, 1));
controlButton->setPosition(ccp(640/2, 960/5));
addChild(controlButton);
/* 当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围内,则触发一次 */
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(GeneralDialogTest::touchUpInside), CCControlEventTouchUpInside);
return true;
}
return false;
}
示例2: tableCellAtIndex
CCTableViewCell* RPGMapItemsMenuLayer::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
CCTableViewCell *cell = tableView->dequeueCell();
if (!cell)
{
cell = new CCTableViewCell();
cell->autorelease();
}
else
cell->removeAllChildrenWithCleanup(true);
float x = 100;
for (int i = 0; i < 4; i++)
{
int index = idx * 4 + i;
if(index >= this->m_itemsList->count())
break;
RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(index);
CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
itemBtn->setPosition(ccp(x, 0));
itemBtn->setTag(itemsData->m_dataId);
itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
cell->addChild(itemBtn);
x += 200;
}
return cell;
}
示例3: 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;
}
示例4: init
bool ParticleTest::init(){
CCControlButton *btn = CCControlButton::create("particle ", "Arial", 24);
btn->setPosition(ccp(320, 1000));
this->addChild(btn);
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(ParticleTest::btnClick), CCControlEventTouchDown);
return true;
}
示例5: 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;
}
示例6: init
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
//获取可视区域尺寸大小
CCSize mysize = CCDirector::sharedDirector()->getVisibleSize();
//获取可视区域的原点位置
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
//屏幕正中心位置
CCPoint midPos = ccp(mysize.width/2, mysize.height/2);
//显示按钮状态的标签displayLabel
displayLabel = CCLabelTTF::create("No Event", "Marker Felt", 32);
displayLabel->setPosition( midPos + ccp(0, 100) );
this->addChild(displayLabel);
//按钮中的背景精灵CCScale9Sprite
CCScale9Sprite* bgNormal = CCScale9Sprite::create("btnNormal.png"); //正常背景
CCScale9Sprite* bgHighlighted = CCScale9Sprite::create("btnHighlighted.png"); //高亮背景
//按钮中的标签CCLabelTTF
CCLabelTTF* titleNormal = CCLabelTTF::create("Button is Normal !", "Marker Felt", 30);
CCLabelTTF* titleHighlighted = CCLabelTTF::create("Button is Highlighted !", "Marker Felt", 30);
//创建按钮CCControlButton
CCControlButton* btn = CCControlButton::create(titleNormal, bgNormal);
btn->setPosition( midPos );
this->addChild(btn);
//设置按钮高亮时的状态
btn->setTitleLabelForState(titleHighlighted, CCControlStateHighlighted); //高亮标签
btn->setTitleColorForState(ccRED, CCControlStateHighlighted); //红色
btn->setBackgroundSpriteForState(bgHighlighted, CCControlStateHighlighted); //高亮背景
//写了这句话,反而大小被固定了。没有按照label的大小进行自动伸展了
//btn->setPreferredSize( CCSizeMake(120,40) );
//绑定事件,用于显示按钮状态
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown); //刚刚开始触摸按钮时
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragInsideAction), CCControlEventTouchDragInside); //在内部拖动时(保持触摸状态下)
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragOutsideAction), CCControlEventTouchDragOutside); //在外部拖动时(保持触摸状态下)
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragEnterAction), CCControlEventTouchDragEnter); //拖动刚进入内部时(保持触摸状态下)
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragExitAction), CCControlEventTouchDragExit); //拖动刚离开内部时(保持触摸状态下)
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpInsideAction), CCControlEventTouchUpInside); //在内部抬起手指(保持触摸状态下)
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpOutsideAction), CCControlEventTouchUpOutside); //在外部抬起手指(保持触摸状态下)
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchCancelAction), CCControlEventTouchCancel); //取消触点
return true;
}
示例7: jumpBtn
void guankaScene::jumpBtn() {
CCSize screenSize = CCDirector::sharedDirector()->getVisibleSize();
CCLabelTTF* jumptext = CCLabelTTF::create("Jump!!", "Arial", 40);
CCScale9Sprite* noDownbtn = CCScale9Sprite::create("button.png");
CCScale9Sprite* downbtn = CCScale9Sprite::create("buttonDown.png");
CCControlButton* Btnjump = CCControlButton::create(jumptext, noDownbtn);
Btnjump->setPosition(ccp(screenSize.width-80, 50));
Btnjump->setBackgroundSpriteForState(downbtn, extension::CCControlStateHighlighted);
Btnjump->addTargetWithActionForControlEvents(this, cccontrol_selector(guankaScene::jumpEvent),CCControlEventTouchDown);
this->addChild(Btnjump,1);
}
示例8: tableCellAtIndex
CCTableViewCell* RPGBattleMenu::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
CCTableViewCell *cell = tableView->dequeueCell();
if (!cell)
{
cell = new CCTableViewCell();
cell->autorelease();
}
else
cell->removeAllChildrenWithCleanup(true);
if(dynamic_cast<RPGSkillBtnData*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
{
//点击了技能项
RPGSkillBtnData *itemsData = (RPGSkillBtnData*)this->m_tableItems->objectAtIndex(idx);
CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_MP)->getCString(), "Arial", 22);
itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
itemBtn->setTag(itemsData->m_dataId);
itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
cell->addChild(itemBtn);
}
else if(dynamic_cast<RPGExistingItems*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
{
//点击了道具项
RPGExistingItems *itemsData = (RPGExistingItems*)this->m_tableItems->objectAtIndex(idx);
CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
itemBtn->setTag(itemsData->m_dataId);
itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
cell->addChild(itemBtn);
}
return cell;
}
示例9: refreshWorldPad
void GamePan::refreshWorldPad()
{
CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
CCLabelTTF* itemTemp = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(kTagGamePanWordPanItemTitle));
CCControlButton* tabItem = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(kTagGamePanWordPanTabBaseItem));
float itemWidth = tabItem->getContentSize().width+ITEM_SPACE;
float itemHeight = tabItem->getContentSize().height+ITEM_SPACE;
for(int i =0;i<MAX_LINE;i++)
{
for(int j =0;j<MAX_ROW;j++)
{
CCControlButton* item = CCControlButton::create();
Utils::copyCCControlButton(item,tabItem);
item->setPosition(ccp(tabItem->getPositionX()+j*itemWidth,tabItem->getPositionY()-i*itemHeight));
item->setTag(j+i*MAX_ROW);
tabNode->addChild(item);
CCLabelTTF* title = Utils::copyCCLabelTTF(itemTemp);
title->setPosition(item->getPosition());
title->setTag(j+i*MAX_ROW);
itemNode->addChild(title);
CCString* str = (CCString*)_wordList->randomObject();
title->setString(str->getCString());
_wordList->removeObject(str);
}
}
for(int i =0;i<MAX_LINE;i++)
{
for(int j =0;j<MAX_ROW;j++)
{
CCControlButton* item = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(j+i*MAX_ROW));
XCheckBox* pCheckBox = XCheckBox::create(item);
pCheckBox->setTag(item->getTag());
pCheckBox->setToggle(false);
pCheckBox->setTarget(this, cccontrol_selector(GamePan::wordSelectCallbackCCControl));
tabNode->addChild(pCheckBox);
item->removeFromParent();
}
}
itemTemp->removeFromParent();
tabItem->removeFromParent();
refreshLetter();
}
示例10: 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;
CCARRAY_FOREACH(stringArray, pObj)
{
CCString* title = (CCString*)pObj;
// Creates a button with this string as title
CCControlButton *button = standardButtonWithTitle(title->getCString());
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;
}
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;
}
示例11: 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;
}
示例12: 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);
}
}
示例13: 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);
//.........这里部分代码省略.........
示例14: init
bool CPullMachHelpLayer::init()
{
if (!CCLayer::init())
return false;
CCSize barDownSize; //µ×Ãæ±ß¿ò³ß´ç
CCSize barUpSize; //ÉÏÃæ±ß¿ò³ß´ç
CCSize infoBgSize; //ÐÅÏ¢±³¾°³ß´ç
CCSize infoViewSize; //ÐÅÏ¢¿ÉÊӳߴç
CCSprite * pSprite = NULL;
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Bar_Down, pSprite))
{
barDownSize = pSprite->getContentSize();
pSprite->setAnchorPoint(CCPointZero);
pSprite->setPosition(CCPointZero);
this->addChild(pSprite);
}
{
float fHeight = this->getContentSize().height - 200;
infoBgSize.setSize(barDownSize.width, (fHeight > 600) ? 600 : fHeight);
CCLayerColor * bgLayer = CCLayerColor::create(ccc4(0, 24, 85, 255), infoBgSize.width, infoBgSize.height);
bgLayer->setPosition(ccp(0, barDownSize.height));
this->addChild(bgLayer);
}
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Bar_Up, pSprite))
{
barUpSize = pSprite->getContentSize();
pSprite->setAnchorPoint(CCPointZero);
pSprite->setPosition(ccp(0, barDownSize.height + infoBgSize.height));
this->addChild(pSprite);
}
//Ìí¼Ó¹ö¶¯ÄÚÈÝ
infoViewSize.setSize(infoBgSize.width - 20, infoBgSize.height);
if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Info, pSprite))
{
pSprite->setAnchorPoint(ccp(0.5f, 0.0f));
pSprite->setPosition(ccp(infoViewSize.width / 2, 0));
}
CCLayerColor * layerColor = CCLayerColor::create(ccc4(0, 13, 32, 255), infoViewSize.width, pSprite->getContentSize().height);
layerColor->setPosition(CCPointZero);
layerColor->addChild(pSprite);
m_pScroll = CCScrollView::create();
m_pScroll->setViewSize(infoViewSize);
m_pScroll->setPosition(ccp(10, barDownSize.height));
m_pScroll->setDirection(kCCScrollViewDirectionVertical);
m_pScroll->addChild(layerColor);
m_pScroll->setContentSize(layerColor->getContentSize());
m_pScroll->setContentOffset(m_pScroll->minContainerOffset());
m_pScroll->setTouchPriority(kCCMenuHandlerPriority - 1);
this->addChild(m_pScroll);
this->setContentSize(CCSize(infoBgSize.width, barDownSize.height + barUpSize.height + infoBgSize.height));
//Ìí¼Ó¹Ø±Õ°´Å¥
CCControlButton* pCloseButton = m_pResManager->CreateControlButton(PullMach_Bt_Help_Close_N, PullMach_Bt_Help_Close_C);
pCloseButton->setAnchorPoint(ccp(1, 1));
pCloseButton->setPosition(getContentSize().width - 10, getContentSize().height - 4);
pCloseButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CPullMachHelpLayer::OnTouchClose), CCControlEventTouchUpInside);
pCloseButton->setScaleX(1.5f);
this->addChild(pCloseButton);
return true;
}
示例15: 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;
}