CCEditBox输入框的使用方法

可以用来当做用户名和密码的输入框

CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCScale9Sprite * spriteUsername = CCScale9Sprite::create("bg.png");
	CCEditBox * username = CCEditBox::create(CCSizeMake(380,60), spriteUsername);
	username->setFontColor(ccc3(255, 255, 255));
	username->setPlaceHolder("input username");//没有内容的时候提示
	username->setMaxLength(5);
	username->setInputFlag(kEditBoxInputFlagSensitive);
	username->setReturnType(kKeyboardReturnTypeDone);
	username->setPosition(ccp(size.width*0.5, 220));
	addChild(username);

	CCScale9Sprite  * spritePassword =CCScale9Sprite::create("bg.png");
	CCEditBox * password = CCEditBox ::create(CCSizeMake(380, 60), spritePassword);
	password->setPosition(ccp(size.width* 0.5, 120));
	password->setFontColor(ccc3(255, 0, 0));
	password->setPlaceHolder("input password");
	password->setMaxLength(12);
	password->setInputFlag(kEditBoxInputFlagPassword);
	password->setReturnType(kKeyboardReturnTypeGo);
	addChild(password);

 

你可能感兴趣的:(it)