【10】coco2d-x CCTextFieldTTF最简单的方法实现密码登陆“*”
来源:互联网 发布:js中的奇偶选择器 编辑:程序博客网 时间:2024/05/07 23:19
最简单的方法使用CCTextFieldTTF设置图密码框,
首先类的继承关系
class Login:public cocos2d::CCLayer,CCIMEDelegate,CCTextFieldDelegate
最有是这几个方法
// CCTextFieldDelegatevirtual bool onTextFieldAttachWithIME(CCTextFieldTTF * pSender);virtual bool onTextFieldDetachWithIME(CCTextFieldTTF * pSender);virtual bool onTextFieldInsertText(CCTextFieldTTF * pSender, const char * text, int nLen);virtual bool onTextFieldDeleteBackward(CCTextFieldTTF * pSender, const char * delText, int nLen);virtual bool onDraw(CCTextFieldTTF * pSender);
先在这个bool Login::onTextFieldInsertText(CCTextFieldTTF * pSender, const char * text, int nLen)方向里加入以下代码
int count=((pSender->getCharCount())>0?(pSender->getCharCount()):1);
if (count<=0)
{
count=1;
}
std::string paSt(count,'*');
pSender->setString(paSt.c_str());
这样,每输入一个字符,上一个字符就变成了“*”
输入接收后,这这个bool Login::onTextFieldDetachWithIME(CCTextFieldTTF * pSender)方法里
std::string pstr=pSender->getPlaceHolder();
if (pstr=="password...")
{
std::string *inpstr=pSender->m_pInputText;
std::string showstr(inpstr->c_str(),0,inpstr->length()-1);
pSender->setString(showstr.c_str());
}
这样就全部显示成了“*”
注意这里pSender->m_pInputText;会报错了,进入CCTextFieldTTF.h,将m_pInputText该成public的就OK了!
本方法也许会有问题!因为修改了框架源码!但是我暂时没有发现!本人也在学习中,发现问题的希望大家留意讨论!
- 【10】coco2d-x CCTextFieldTTF最简单的方法实现密码登陆“*”
- COCO2D-X中ScrollView的使用实现
- coco2d-x单例的实现
- 简单的密码登陆
- Hadoop集群最迅速的配置免密码登陆方法
- CCClippingNode 的简单使用(coco2d-x 2.2.4)
- coco2d-x中引用离子效果,游戏计数的方法
- Cocos2d-X中使用CCTextFieldTTF的简单应用显示文本和弹出软键盘
- Cocos2d-x中使用CCTextFieldTTF的简单应用显示文本和弹出软键盘
- cocosd-x教程4 CCTextFieldTTF的使用
- win32平台下:cocos2d-x中继承并重写CCTextFieldTTF类,实现密码框输入时,*显示
- 最简单的单点登陆SSO系统的实现思路
- coco2d-x 3.x 实现帧动画
- 最简单的VPN登陆
- 记住密码实现登陆功能,简单,易懂。
- Android 登陆页面 记住密码和自动登陆的简单实现
- Android登陆界面的简单实现(登陆背景渐变,密码点击隐藏与显示)
- 最简单的破解windows登录密码的方法
- 【黑马程序员】Java基础08:IO流来流去...
- 硬盘知识
- 利用C#查询Excel,并以Dataset返回结果
- [leet code] Remove Element
- C++中操作符重载
- 【10】coco2d-x CCTextFieldTTF最简单的方法实现密码登陆“*”
- Ubuntu下搭建SVN+Apache
- __cdecl __stdcall区别
- Type Inference vs. Static/Dynamic Typing
- 第一次参加投融资峰会获奖
- vs2012 项目加载失败解决方法
- 用java的api将数据从HDFS上存到HBASE中
- 如何在安装的lnmp一键环境包(nginx)启用pathinfo URL模式
- LeetCode Status