//继承(class HelloWorld : public cocos2d::CCLayer, public cocos2d::CCTextFieldDelegate)

CCTextFieldTTF* textField = CCTextFieldTTF::textFieldWithPlaceHolder("Click input...", "Helvetica", );
textField->setPosition(ccp(size.width*0.5,size.height*0.7));
addChild(textField); //绑定接口
textField->setDelegate(this);
//开启输入
textField->attachWithIME();
//关闭输入
//textField->detachWithIME();

5种常用CCMenuItem

//----CCMenuItemImage
/*
*CCMenuItemImage::create(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector)
*
*参1:正常显示的图片
*参2:用户选中后显示图片
*参3:触发的目标对象
*参4:触发的目标函数
*/
CCMenuItemImage *menuItemImage = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! menuItemImage);
menuItemImage->setPosition(ccp(,)); //----CCMenuItemFont
/*
*CCMenuItemFont * CCMenuItemFont::create(const char *value, CCObject* target, SEL_MenuHandler selector)
*
*参1:显示的文字
*参2:触发的目标对象
*参3:触发的目标函数
*/
CCMenuItemFont* menuItemFont = CCMenuItemFont::create("ItemFont",this,menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! menuItemFont);
menuItemFont->setPosition(, ); //----CCMenuItemLabel
/*
*CCMenuItemLabel::create(CCNode*label, CCObject* target, SEL_MenuHandler selector)
*
*参1:CCLabelTTF 对象
*参2:触发的目标对象
*参3:触发的目标函数
*/
CCLabelTTF* lableTTF = CCLabelTTF::create("ItemLabel", "Helvetica", );
CCMenuItemLabel* menuItemLabel = CCMenuItemLabel::create(lableTTF,this,menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! menuItemLabel);
menuItemLabel->setPosition(,); //----CCMenuItemSprite
/*
*CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector)
*
*参1:未选中的显示 CCSprite 对象
*参2:选中的显示 CCSprite 对象
*参3:触发的目标对象
*参4:触发的目标函数
*/
CCSprite* spNor = CCSprite::create("Icon.png");
spNor->setColor(ccc3(, , ));
CCSprite* spSelected =CCSprite::create("Icon.png");
CCMenuItemSprite* spriteItem = CCMenuItemSprite::create(spNor,spSelected, this,menu_selector(HelloWorld::menuCloseCallback));
spriteItem->setPosition(ccp(,)); //----CCMenuItemToggle
/*
*CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...)
*
*参1:触发的目标对象
*参2:触发的目标函数
*参3:CCMenuItem 对象的可变参数列表
*/
CCMenuItemFont * fontItem1 = CCMenuItemFont::create("Music ON");
CCMenuItemFont * fontItem2 = CCMenuItemFont::create("Music OFF");
CCMenuItemToggle* toggleItem = CCMenuItemToggle::createWithTarget(this,NULL/*menu_selector(HelloWorld::menuCloseCallback)*/, fontItem1,fontItem2,NULL);
toggleItem->setPosition(ccp(,)); CCMenu* pMenu = CCMenu::create(menuItemImage, menuItemFont, menuItemLabel, spriteItem, toggleItem, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu); this->addChild(pMenu, );
05-20 08:12