本文整理汇总了C++中CCEditBox::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCEditBox::setPosition方法的具体用法?C++ CCEditBox::setPosition怎么用?C++ CCEditBox::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCEditBox
的用法示例。
在下文中一共展示了CCEditBox::setPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MainMenuBarLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
// Display Size
CCSize visibleSize = pDirector->getVisibleSize();
// Background Image for menu bar
CCScale9Sprite* scale9Sprite = CCScale9Sprite::create("frame_v.png");
scale9Sprite->setContentSize(ccp(visibleSize.width,visibleSize.height/10));
scale9Sprite->setPosition(ccp(visibleSize.width/2,visibleSize.height - scale9Sprite->getContentSize().height/2));
this->addChild(scale9Sprite,4);
// Go back to privious scene
CCMenuItemImage* menuBackItem = CCMenuItemImage::create("frame_g.png","frame_p.png",this,menu_selector(MainMenuBarLayer::goBackScene));
menuBackItem->setPosition(ccp(menuBackItem->getContentSize().width/2, visibleSize.height - menuBackItem->getContentSize().height/2));
CCMenu* menuBack = CCMenu::create(menuBackItem, NULL);
menuBack->setPosition(CCPointZero);
//this->addChild(menuBack);
// Send a message
CCMenuItemImage* sendItemImg = CCMenuItemImage::create("frame_g.png","frame_p.png",this,menu_selector(MainMenuBarLayer::goBackScene));
sendItemImg->setPosition(ccp(visibleSize.width - sendItemImg->getContentSize().width/2, visibleSize.height - sendItemImg->getContentSize().height/2));
CCMenu* menuSend = CCMenu::create(sendItemImg, NULL);
menuSend->setPosition(CCPointZero);
//this->addChild(menuSend);
// EditBox
CCEditBox* editBox;
CCSize editBoxSize = CCSizeMake(100, 100);
editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("frame_g.png"));
editBox->setPosition(ccp(visibleSize.width - sendItemImg->getContentSize().width/2, visibleSize.height - sendItemImg->getContentSize().height/2));
editBox->setFontColor(ccBLUE);
editBox->setPlaceHolder("");
editBox->setMaxLength(100);
editBox->setFontSize(24);
editBox->setDelegate(this);
editBox->setTag(_EDITBOX_);
editBox->setInputMode(kEditBoxInputModeAny);
//editBox->setReturnType(kKeyboardReturnTypeSend);
this->addChild(editBox,5);
// End
return true;
}
示例2: initTopMenu
bool CCLobbyView::initTopMenu()
{
CCDirector* director = CCDirector::sharedDirector();
const CCSize winSize = director->getWinSize();
const CCSize mySize = this->getContentSize();
const CCPoint center = ccpMult( ccpFromSize( mySize ), 0.5f );
CCLabelTTF* consoleLabel = CCLabelTTF::create( "disconnected", "Arial", FONT_SIZE(24), CCSizeMake( winSize.width, FONT_SIZE(24) ), kCCTextAlignmentCenter );
consoleLabel->setColor( ccc3(255, 255, 255) );
CCMenuItemLabel* consoleItem = CCMenuItemLabel::create( consoleLabel );
// bottom
const CCSize editSize = CCSizeMake( winSize.width, FONT_SIZE(48) );
CCMenuItem* editItem = CCMenuItem::create();
editItem->setContentSize( editSize );
CCMenu* topMenu = CCMenu::create( consoleItem, editItem, NULL );
if( topMenu )
{
this->setConsole( consoleLabel );
topMenu->alignItemsVertically();
topMenu->setPosition( CCPointMake( center.x, winSize.height - (editItem->getContentSize().height + consoleItem->getContentSize().height)/2 ) );
this->addChild( topMenu, 0, Child::CCMenu_topMenu );
const CCPoint editItemPosition = editItem->getParent()->convertToWorldSpace( editItem->getPosition() );
editItem->setContentSize( winSize );
editItem->ignoreAnchorPointForPosition( false );
editItem->setAnchorPoint( ccp( 0.5f, (winSize.height / (editItemPosition.y - winSize.height)) * 0.5f ) );
CCScale9Sprite* editSprite = CCScale9Sprite::create("extensions/yellow_edit.png");
CCEditBox* edit = CCEditBox::create( editSize, editSprite );
edit->setPlaceHolder("PlayerName");
edit->setReturnType(kKeyboardReturnTypeDone);
edit->setFontColor(ccGRAY);
edit->setMaxLength( 20 );
edit->setDelegate(this);
edit->setTouchEnabled( true );
edit->setPosition( editItemPosition );
CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
JString userName = network->getUserName();
edit->setText(userName.UTF8Representation().cstr());
this->addChild( edit );
this->setEditName(edit);
}
return topMenu;
}
示例3: init
bool TweetScene::init()
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCSize editBoxSize = CCSizeMake(visibleSize.width/2, 50);
CCEditBox* editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("9patch.png"));
editBox->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
editBox->setFontColor(ccWHITE);
editBox->setPlaceHolder("TextBox");
editBox->setReturnType(kKeyboardReturnTypeDone);
editBox->setTag(1);
this->addChild(editBox);
CCLabelTTF* tweetLabel = CCLabelTTF::create("つぶやく", "arial", 48);
CCMenuItemLabel* tweetItem = CCMenuItemLabel::create(tweetLabel, this, menu_selector(TweetScene::tweet));
tweetItem->setPosition(ccp(visibleSize.width/2,visibleSize.height-tweetLabel->getContentSize().height));
CCMenu* tweetMenu = CCMenu::create(tweetItem,NULL);
tweetMenu->setPosition(CCPointZero);
this->addChild(tweetMenu);
return true;
}
示例4: LogInTableDraw
void LogInScene::LogInTableDraw(int _index){
CCMenu* popUpMenu = (CCMenu*)popUpMenuLayer->getChildByTag(998);
CCMenu* beginMenu = (CCMenu*)this->getChildByTag(997);
popUpMenu->setTouchEnabled(false);
if (beginMenu!=NULL)
beginMenu->setTouchEnabled(false);
//1.基本层
AccountLayer = CCLayer::create();
AccountLayer->setPosition(CCPointZero);
addChild(AccountLayer,10);
//2.黑色遮罩:不在该移动层上
CCLayerColor* black = CCLayerColor::create(ccc4(0, 0, 0, 155));
black->setPosition(CCPointZero);
AccountLayer->addChild(black,0);
//3.木板
CCSprite* LogInTable = CCSprite::createWithSpriteFrameName("LogInTable.png");
LogInTable->setPosition(ccp(size.width/2, size.height/2+winDif*2));
AccountLayer->addChild(LogInTable,1);
//3.edit box - user name
CCScale9Sprite *UserNameTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
CCEditBox *UserNameBox=CCEditBox::create(CCSizeMake(195, 44), UserNameTexture);
UserNameBox->setPosition(ccp(size.width*8/15, size.height*0.561+winDif*2));
UserNameBox->setFontName("Arial Rounded MT bold");
UserNameBox->setMaxLength(20);
UserNameBox->setInputMode(kEditBoxInputModeAny);
UserNameBox->setInputFlag(kEditBoxInputFlagSensitive);
UserNameBox->setReturnType(kKeyboardReturnTypeDone);
UserNameBox->setDelegate(this);
AccountLayer->addChild(UserNameBox,2,10);
//4.edit box - password
CCScale9Sprite *PasswordTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
CCEditBox *PasswordBox = CCEditBox::create(CCSizeMake(195, 44), PasswordTexture);
PasswordBox->setPosition(ccp(size.width*8/15, size.height*0.486+winDif*2));
PasswordBox->setFontName("Arial Rounded MT bold");
PasswordBox->setMaxLength(50);
PasswordBox->setInputMode(kEditBoxInputModeAny);
PasswordBox->setInputFlag(kEditBoxInputFlagPassword);
PasswordBox->setReturnType(kKeyboardReturnTypeDone);
PasswordBox->setDelegate(this);
AccountLayer->addChild(PasswordBox,2,11);
//5.登录注册按钮
CCMenuItemSprite* Item1;
if (_index == 0){
CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("signUpButtonGreen.png");
CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("signUpButtonGreen-s.png");
Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::SignUpHTTP));
}
else if (_index == 1){
CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("binding.png");
CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("binding-s.png");
Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::bindUserAccountHTTP));
}
else if (_index == 2){
CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("LogInButton.png");
CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("LogInButton-s.png");
Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::LogInHTTP));
}
CCSprite* item2Sprite = CCSprite::createWithSpriteFrameName("cancelButton.png");
CCSprite* item2Sprite_s = CCSprite::createWithSpriteFrameName("cancelButton-s.png");
CCMenuItemSprite* Item2 = CCMenuItemSprite::create(item2Sprite,item2Sprite_s,this,menu_selector(LogInScene::closeThisLayer));
Item1->setPosition(ccp(winSize.width*11.5/30,size.height*0.42+winDif*2));
Item2->setPosition(ccp(winSize.width*18.5/30,size.height*0.42+winDif*2));
CCMenu* LogInMenu = CCMenu::create(Item1,Item2,NULL);
LogInMenu->setPosition(CCPointZero);
AccountLayer->addChild(LogInMenu,3);
}
示例5: 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;
}
示例6: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCScale9Sprite* sacel9SprY = CCScale9Sprite::create("[email protected]");
CCEditBox* box = CCEditBox::create(CCSizeMake(200, 80), sacel9SprY);
//设置编辑框内的文字
// box->setText("xcc");
//设置位置
box->setPosition(ccp(200, 200));
//获取编辑框内的文字
CCLOG("Text:%s",box->getText());
box->setDelegate(this);
//设置文本的颜色
box->setFontColor(ccc3(255, 0, 0));
//当编辑框中没有任何字符的提示
box->setPlaceHolder("请输入账号:");
//最大输入文本长度
box->setMaxLength(3);
box->setInputMode(kEditBoxInputModeAny);
// kEditBoxInputModeAny: 开启任何文本的输入键盘,包括换行
// kEditBoxInputModeEmailAddr: 开启 邮件地址 输入类型键盘
// kEditBoxInputModeNumeric: 开启 数字符号 输入类型键盘
// kEditBoxInputModePhoneNumber: 开启 电话号码 输入类型键盘
// kEditBoxInputModeUrl: 开启 URL 输入类型键盘
// kEditBoxInputModeDecimal: 开启 数字 输入类型键盘,允许小数点
// kEditBoxInputModeSingleLine: 开启任何文本的输入键盘,不包括换行
box->setReturnType(kKeyboardReturnTypeSearch);
// kKeyboardReturnTypeDefault: 默认使用键盘return 类型
// kKeyboardReturnTypeDone: 默认使用键盘return类型为“Done”字样
// kKeyboardReturnTypeSend: 默认使用键盘return类型为“Send”字样
// kKeyboardReturnTypeSearch: 默认使用键盘return类型为“Search”字样
// kKeyboardReturnTypeGo: 默认使用键盘return类型为“Go”字样
//设置该属性输入密码时为替代符
box->setInputFlag(kEditBoxInputFlagPassword);
this->addChild(box);
return true;
}
示例7: 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 );
//.........这里部分代码省略.........