cocos2d-x3.0输入框
来源:互联网 发布:日本机器人 知乎 编辑:程序博客网 时间:2024/05/16 11:01
我要实现很简单的像下面的东东:
左边的是LabelTTF,右边用EditBox。这里有个建议,大家写代码的就不要再用CC前缀的,有命名空间了还用那玩意干毛呢。。。纯粹是cocos2d-x作者仿制的cocos2d的不好的东东。
好,下面写代码了:
CCDictionary *strings = CCDictionary::createWithContentsOfFile("word.xml");const char *keyWordsFind = ((String*)strings->objectForKey("KeyWordsFind"))->getCString();const char *suarAyaFind = ((CCString*)strings->objectForKey("SuarAyaFind"))->getCString();auto labelKeywordFind = LabelTTF::create(keyWordsFind, "Arial", 24);labelKeywordFind->setPosition( ccp(labelKeywordFind->getContentSize().width/2 , visibleSize.height - 50) );addChild(labelKeywordFind, 1);auto labelSuraAyaFind = LabelTTF::create(suarAyaFind, "Arial", 24);labelSuraAyaFind->setPosition( ccp(labelSuraAyaFind->getContentSize().width/2, visibleSize.height - 100) );labelSuraAyaFind->setAnchorPoint(ccp(0.5,0.5));addChild(labelSuraAyaFind, 1);auto keyWordFindBox = createMyEditBox("test.png", CCSizeMake(200, 30),ccp(labelKeywordFind->getContentSize().width+100, visibleSize.height - 50) );auto suraAyaFindBox = createMyEditBox("test.png", CCSizeMake(200, 30),ccp(labelSuraAyaFind->getContentSize().width+100, visibleSize.height - 100) );addChild(keyWordFindBox, 1);addChild(suraAyaFindBox,1);
createMyEditBox函数是我订制的一个函数,因为很多东西一样,避免重复代码。
EditBox* HelloWorld::createMyEditBox( std::string spriteFolder,Size& size, Point& position ){CCScale9Sprite* sacel9Spr = CCScale9Sprite::create(spriteFolder.c_str());auto box = CCEditBox::create(size, sacel9Spr);box->setPosition(position);box->setFontColor(ccc3(255, 228, 173));box->setInputMode(kEditBoxInputModeAny);box->setInputFlag(kEditBoxInputFlagInitialCapsWord);box->setFont("Arial", 24);return box;}
效果是上图。
- cocos2d-x3.0输入框
- Cocos2d-x3.0 EventListener
- cocos2d-x3.0 SpriteFrameCache
- Cocos2d-x3.0触摸
- Cocos2d-x3.0 Button
- Cocos2d-x3.0 LoadingBar
- cocos2d-x3.0 PageView
- cocos2d-x3.0 RichText
- cocos2d-x3.0 ScrollView
- cocos2d-x3.0 Slider
- cocos2d-x3.0 ListView
- cocos2d-x3.0
- cocos2d-x3.0 柱图
- cocos2d-x3.0学习1
- cocos2d-x3.0 touch研究
- xcode安装cocos2d-x3.0
- cocos2d-x3.0的HelloWorld
- cocos2d-x3.0RC2 TableViewDemo
- 网站前端性能优化
- 对象的序列化和反序列化
- 常见C/C++ XML解析器比较
- strcpy,strncpy和strncpy_s的区别 strncpy函数与memcpy函数
- Android虚拟机提示The connection to adb is down, and a severe error has occured
- cocos2d-x3.0输入框
- 3DMAX经典问答---材质部分(3)
- ubuntu server 安装桌面环境中文乱码问题
- Thinkpad x230i预装Windows 8的机型更换Windows 7及XP的常规设置方法
- MYSQL limit,offset 区别
- Cocos2d-x学习之---关于一些宏
- EXt4.0的动态二级联动
- drupal主题化常用函数集锦
- 第四届蓝桥杯--剪格子