本文整理汇总了C++中CCEditBox::setTouchEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ CCEditBox::setTouchEnabled方法的具体用法?C++ CCEditBox::setTouchEnabled怎么用?C++ CCEditBox::setTouchEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCEditBox
的用法示例。
在下文中一共展示了CCEditBox::setTouchEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}