cocos2dx TextFieldTTF

前端之家收集整理的这篇文章主要介绍了cocos2dx TextFieldTTF前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
auto tf = TextFieldTTF::textFieldWithPlaceHolder("请输入本局昵称","宋体",30);
    tf->setPosition(visibleSize / 2);
    this->addChild(tf);

    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = [tf](Touch* touch,Event* event) {
        if (tf->getBoundingBox().containsPoint(touch->getLocation())) {
            tf->attachWithIME();     //调用输入法
        }else{
            tf->detachWithIME();     //关闭输入法
        }
        return false;
    };
    Director::getInstance()->getEventDispatcher()->
        addEventListenerWithSceneGraPHPriority(listener,tf);
    tf->getString();                //获取内容

猜你在找的Cocos2d-x相关文章