void CocosGUIExamplesRegisterScene::onEnter() { CCScene::onEnter(); m_pUILayer = UILayer::create(); m_pUILayer->scheduleUpdate(); addChild(m_pUILayer); // register root from json m_pLayout = dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/gui_examples/register_1/register_1.json")); m_pUILayer->addWidget(m_pLayout); // e-mail layout UILayout* eMail_layout = dynamic_cast<UILayout*>(m_pLayout->getChildByName("e-mail_Panel")); // ui node container add to e-mail layout UINodeContainer* nodeContainer = UINodeContainer::create(); nodeContainer->setPosition(ccp(eMail_layout->getContentSize().width / 2, eMail_layout->getContentSize().height / 2)); #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) // CCEditBox add to ui node container CCSize editBoxSize = eMail_layout->getContentSize(); CCEditBox* email_editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("cocosgui/gui_examples/register_1/e-mail.png")); email_editBox->setFontName("SongTypeFont"); email_editBox->setFontSize(20); email_editBox->setPlaceholderFontColor(ccc3(127, 127, 127)); email_editBox->setPlaceHolder("Email"); email_editBox->setInputMode(kEditBoxInputModeEmailAddr); nodeContainer->addCCNode(email_editBox); // add ui node container to layout eMail_layout->addChild(nodeContainer); #else #pragma message ("Warning: CCEditBox not implmented for CC_PLATFORM_WINRT and CC_PLATFORM_WP8") #endif // content panel UILayout* content_panel = dynamic_cast<UILayout*>(m_pLayout->getChildByName("content_Panel")); // password textfield add event UITextField* passwordAgin_textfield = dynamic_cast<UITextField*>(content_panel->getChildByName("password agin_TextField")); passwordAgin_textfield->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(CocosGUIExamplesRegisterScene::attachWithIMEEvent)); passwordAgin_textfield->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(CocosGUIExamplesRegisterScene::detachWithIMEEvent)); // register button UILayout* register_button_panel = dynamic_cast<UILayout*>(m_pLayout->getChildByName("register button_Panel")); UIButton* button = dynamic_cast<UIButton*>(register_button_panel->getChildByName("register_Button")); button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesRegisterScene::toCocosGUIExamplesEquipScene)); // back button UIButton* back_button = UIButton::create(); back_button->setTouchEnable(true); back_button->loadTextures("cocosgui/UITest/b1.png", "cocosgui/UITest/b2.png", ""); back_button->setPosition(ccp(back_button->getContentSize().width, back_button->getContentSize().height)); back_button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesRegisterScene::toCocosGUIScene)); // back_button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesRegisterScene::toCocosGUIExamplesStartScene)); m_pUILayer->addWidget(back_button); }
UINodeContainer* UINodeContainer::create() { UINodeContainer* widget = new UINodeContainer(); if (widget && widget->init()) { return widget; } CC_SAFE_DELETE(widget); return NULL; }
bool UINodeContainerTest::init() { if (UIScene::init()) { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Add a label in which the UINodeContainer alert will be displayed m_pDisplayValueLabel = UILabel::create(); m_pDisplayValueLabel->setText("NodeContainer Add CCNode"); m_pDisplayValueLabel->setFontName("Marker Felt"); m_pDisplayValueLabel->setFontSize(32); m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1)); // m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + m_pDisplayValueLabel->getContentSize().height * 1.5)); m_pUiLayer->addWidget(m_pDisplayValueLabel); // Add the alert UILabel *alert = UILabel::create(); alert->setText("NodeContainer"); alert->setFontName("Marker Felt"); alert->setFontSize(30); alert->setColor(ccc3(159, 168, 176)); // alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 1.75)); m_pUiLayer->addWidget(alert); // Create the ui node container UINodeContainer* nodeContainer = UINodeContainer::create(); nodeContainer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); m_pUiLayer->addWidget(nodeContainer); CCSprite* sprite = CCSprite::create("cocosgui/ccicon.png"); sprite->setPosition(ccp(0, sprite->boundingBox().size.height / 4)); nodeContainer->addCCNode(sprite); return true; } return false; }