编辑框登录界面的学习
来源:互联网 发布:ubuntu安装deb包命令 编辑:程序博客网 时间:2024/04/30 07:56
//========================.h===========================
#include "cocos2d.h"
#include "cocos-ext.h"
USING_NS_CC;
USING_NS_CC_EXT;
//CCIMEDelegate:打开虚拟键盘类CCTextFieldDelegate:文字标签类
class Logon:publicCCLayer,publicCCIMEDelegate,publicCCTextFieldDelegate,
public CCEditBoxDelegate
{
public:
CCEditBox * userName_editBox;
CCEditBox *passWord_editBox;
CCSprite *loginImgK;
public:
virtual bool init();
static CCScene* scene();
static Logon* creat();
void userlogonbox();
//必须实现CCEditBox其中纯虚函数
virtual void editBoxReturn(CCEditBox* editBox);
};
//========================.cpp===========================
#include "Logon.h"
boolLogon::init()
{
if(CCLayer::init())
{
this->loginImgK=CCSprite::create("HelloWorld.png");
this->addChild(loginImgK);
this->setAnchorPoint(ccp(0.5,0.5));
float a=CCDirector::sharedDirector()->getWinSize().width;
float b=CCDirector::sharedDirector()->getWinSize().height;
this->setPosition(ccp(a/2,b/2));
this->userlogonbox();
return true;
}
return false;
}
CCScene* Logon::scene()
{
CCScene *scene=CCScene::create();
Logon *rp=Logon::creat();
scene->addChild(rp);
return scene;
}
Logon*Logon::creat()
{
Logon *dl = newLogon();
if (dl && dl->init())
{
dl->autorelease();
return dl;
}
else
{
delete dl;
dl =NULL;
return NULL;
}
}
voidLogon::userlogonbox()
{
//设置编辑框大小
CCSize editSize = CCSizeMake(265, 35);
//第一个size参数表示输入编辑框的大小,第二个参数九宫格是用于输入编辑框的背景
userName_editBox =CCEditBox::create(editSize,CCScale9Sprite::create("Icon-Small.png"));
userName_editBox->setAnchorPoint(ccp(0,1));
float x = 120;
float y = loginImgK->getContentSize().height-100;
userName_editBox->cocos2d::CCNode::setPosition(ccp(x,y));
//以setFont开头的有几个方法是用于设置输入文字的字体,大小,颜色
userName_editBox->setFontSize(25);
userName_editBox->setFontColor(ccRED);
//设置输入编辑框在还没有输入的时候默认的提示文字
userName_editBox->setPlaceHolder("帐号: ");
//同样的,也有几个对应的方法的是用于设置这些提示文字的,都是以setPlaceHolder开头的
userName_editBox->setPlaceholderFontColor(ccWHITE);
//设置输入编辑文字的长度,一个字符为一个长度
userName_editBox->setMaxLength(20);
//设置键盘中return键显示的字符
userName_editBox->setReturnType(kKeyboardReturnTypeDone);
userName_editBox->setInputMode(kEditBoxInputModeAny);
//包括这些选项
// kEditBoxInputModeAny: 开启任何文本的输入键盘,包括换行
// kEditBoxInputModeEmailAddr: 开启 邮件地址 输入类型键盘
// kEditBoxInputModeNumeric: 开启 数字符号 输入类型键盘
// kEditBoxInputModePhoneNumber: 开启 电话号码 输入类型键盘
// kEditBoxInputModeUrl: 开启 URL 输入类型键盘
// kEditBoxInputModeDecimal: 开启 数字 输入类型键盘,允许小数点
// kEditBoxInputModeSingleLine: 开启任何文本的输入键盘,不包括换行
//设置委托代理对象为当前类
userName_editBox->setDelegate(this);
loginImgK->addChild(userName_editBox);
/********************** 密码框 *****************************/
//CCSize editSize = CCSizeMake(265, 35);
//第一个size参数表示输入编辑框的大小,第二个参数九宫格是用于输入编辑框的背景
passWord_editBox =CCEditBox::create(editSize,CCScale9Sprite::create("Icon-Small.png"));
passWord_editBox->setAnchorPoint(ccp(0,0));
//float y = CCDirector::sharedDirector()->getWinSize().height * 0.3156;
passWord_editBox->cocos2d::CCNode::setPosition(x,130);
//以setFont开头的有几个方法是用于设置输入文字的字体,大小,颜色
passWord_editBox->setFontSize(25);
passWord_editBox->setFontColor(ccRED);
//设置输入编辑框在还没有输入的时候默认的提示文字
passWord_editBox->setPlaceHolder("密码: ");
//同样的,也有几个对应的方法的是用于设置这些提示文字的,都是以setPlaceHolder开头的
passWord_editBox->setPlaceholderFontColor(ccWHITE);
//设置输入编辑文字的长度,一个字符为一个长度
passWord_editBox->setMaxLength(20);
//设置键盘中return键显示的字符
passWord_editBox->setReturnType(kKeyboardReturnTypeGo);
//设置该属性输入密码时为替代符
passWord_editBox->setInputFlag(kEditBoxInputFlagPassword); //如果只是简单输入字符,则不用这个设置
//包括这些选项
// kEditBoxInputFlagPassword,
// kEditBoxInputFlagSensitive,
// kEditBoxInputFlagInitialCapsWord,
// kEditBoxInputFlagInitialCapsSentence,
// kEditBoxInputFlagInitialCapsAllCharacters
//设置委托代理对象为当前类
passWord_editBox->setDelegate(this);
loginImgK->addChild(passWord_editBox);
}
voidLogon::editBoxReturn(CCEditBox* editBox)
{
}
- 编辑框登录界面的学习
- 登录界面中透明编辑框的实现(测试平台WINCE 5.0)
- Axure登录和注册界面的学习
- weex 学习之登录界面的开发
- eclipse 去掉 java编辑界面和jsp编辑界面xml编辑界面的的悬浮框提示
- SayHello界面的编辑
- 登录界面的设计
- 我的登录界面
- 登录界面的测试
- 登录界面的测试
- 简单的登录界面
- 登录界面的实现
- 漂亮的登录界面
- 登录界面的制作
- 登录界面的全过程
- 登录界面的设计
- 简单的登录界面
- 简单的登录界面
- java正则表达式判断手机号
- C++函数模板 模板实例化、具体化
- python引用,拷贝详解
- Qt编程推荐网站
- 好吃货在美食当中
- 编辑框登录界面的学习
- Android自定义Dialog
- Unity 3D中的内存管理
- 简化实现qt中的信号阻塞blockSignals
- 阿里面试
- 科学解析wifi过敏症
- FIO工具测试IOPS简单说明
- vsftpd 500 OOPS: cannot change directory:/home/***
- nginx泛域名解析并禁止IP访问,禁止多余www.泛域名访问