当前位置: 首页>>代码示例>>C++>>正文


C++ CCEditBox::setTag方法代码示例

本文整理汇总了C++中CCEditBox::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCEditBox::setTag方法的具体用法?C++ CCEditBox::setTag怎么用?C++ CCEditBox::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCEditBox的用法示例。


在下文中一共展示了CCEditBox::setTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:Tetz,项目名称:cocos2dx_demo,代码行数:51,代码来源:MainMenuBarLayer.cpp

示例2: 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;
}
开发者ID:Nush,项目名称:cocos2dx_study,代码行数:22,代码来源:TweetScene.cpp


注:本文中的CCEditBox::setTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。