// 조심해!! 이 레이어가 제대로 작동하는지 알아보려면 Win32 키보드를 지원하지 않아서 iOS에서 돌려봐야해!! // Win32 하드웨어 키보드는 아직 지원하지 않는다고 ㅠㅠ bool CPlayerNameSettingLayer::init() { if ( !CCLayer::init() ) { return false; } // Get Window Size CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); // touch enable == true for iPad keyboard input this->setTouchEnabled(true); CCTextFieldTTF *textfield = CCTextFieldTTF::textFieldWithPlaceHolder("NameInputPage", CCSize(480,30), kCCTextAlignmentCenter, "Arial", 20); // textfield tag == 1; textfield->setTag(1); // set position textfield->setPosition(ccp(visibleSize.width/2, visibleSize.height/2 + 100)); this->addChild(textfield); CCLabelTTF *label = CCLabelTTF::create("NAME : ", "", 50); // label tag = 2; label->setTag(2); // set position label->setPosition(ccp(visibleSize.width/2, visibleSize.height/2 - 100)); this->addChild(label); }
void TextInput::onEnter() { CCLayer::onEnter(); setTouchEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCTextFieldTTF * pTextField = CCTextFieldTTF::textFieldWithPlaceHolder("<click here for input>","Arial",24); addChild(pTextField); pTextField->setPosition(ccp(s.width / 2, s.height / 2)); m_pTrackNode = pTextField; CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, menu_selector(TextInput::menuCloseCallback)); // Place the menu item bottom-right conner. pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); // Create a menu with the "close" menu item, it's an auto release object. CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); pMenu->setPosition(CCPointZero); addChild(pMenu); }
void TextFieldTTFDefaultTest::onEnter() { KeyboardNotificationLayer::onEnter(); // add CCTextFieldTTF CCSize s = CCDirector::sharedDirector()->getWinSize(); CCTextFieldTTF * pTextField = CCTextFieldTTF::textFieldWithPlaceHolder("<click here for input>", FONT_NAME, FONT_SIZE); addChild(pTextField); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // on ANDROID, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up // so we had to set a higher position to make it visable pTextField->setPosition(ccp(s.width / 2, s.height/2 + 50)); #else pTextField->setPosition(ccp(s.width / 2, s.height / 2)); #endif m_pTrackNode = pTextField; }
void LogIntoLayer::creatPasswordText() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCPoint pos = CCPointMake(winSize.width*220/500,winSize.height*22/50); CCTextFieldTTF* text = CCTextFieldTTF::textFieldWithPlaceHolder( "Input Your Password...","Arial",20); text->setColor(ccc3(INPUT_R,INPUT_G,INPUT_B)); text->setPosition(pos); this->addChild(text,20); text->setDelegate(this); text->retain(); passwordText = text; }
void RegisterLayer::creatUsernameText() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCPoint pos = CCPointMake(winSize.width*250/500,winSize.height*35/50); CCTextFieldTTF* text = CCTextFieldTTF::textFieldWithPlaceHolder( "Input Your Name...","Arial",20); text->setColor(ccc3(INPUT_R,INPUT_G,INPUT_B)); text->setPosition(pos); this->addChild(text,20); text->setDelegate(this); text->retain(); usernameText = text; }