一:LabelTTF
是一个文本输出展示控件 例子:
LabelTTF *laber = LabelTTF::create(); laber->setString("Hello World"); laber->setFontSize(36); laber->setPosition(size.width/2,size.height/2); addChild(laber);
二:TextFieldTTF
是文本输出控件 例子:
Size visibleSize = Director::getInstance()->getVisibleSize(); TextFieldTTF *tf = TextFieldTTF::textFieldWithPlaceHolder("在这里输入","宋体",20); tf->setPosition(visibleSize.width/2,visibleSize.height/2); addChild(tf); auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [tf](Touch *t,Event *event){ if(tf->getBoundingBox().containsPoint(t->getLocation())) { tf->attachWithIME(); }else { tf->detachWithIME(); } return false; }; Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraPHPriority(listener,tf);原文链接:https://www.f2er.com/cocos2dx/346509.html