bool KPopupLayer::init() { if (!UILayer::init()) { return false; } m_panel = KJsonDictMgr::getSingleton().widgetFromJsonFile("GUI/popMsg.json"); m_panel->setAnchorPoint(CCPoint(0.5f,0.5f)); addWidget( m_panel ); m_pLabCaption = (UILabel*)getWidgetByName("title"); m_pLabContent = (UILabel*)getWidgetByName("msg"); m_pBtn_Ok = (UIButton*)getWidgetByName("but_ok"); m_pBtn_Ok->addReleaseEvent(this,coco_releaseselector(KPopupLayer::btn_Click)); m_pBtn_Ok->setWidgetTag(RT_Ok); m_pBtn_Yes = (UIButton*)getWidgetByName("but_yes"); m_pBtn_Yes->addReleaseEvent(this,coco_releaseselector(KPopupLayer::btn_Click)); m_pBtn_Yes->setWidgetTag(RT_YES); m_pBtn_No = (UIButton*)getWidgetByName("but_no"); m_pBtn_No->addReleaseEvent(this,coco_releaseselector(KPopupLayer::btn_Click)); m_pBtn_No->setWidgetTag(RT_NO); m_pPushListener = NULL; setTouchEnabled(true); //开启触摸响应 return true; }
bool SettingDialog::init() { if ( !Dialog::initContentWithJsonFile("UI4DialogSet.ExportJson") ) return false; button_music = dynamic_cast<Button*>(getWidgetByName("Button_music")); button_effect = dynamic_cast<Button*>(getWidgetByName("Button_effect")); progress_music = dynamic_cast<LoadingBar*>(getWidgetByName("ProgressBar_music")); progress_effect = dynamic_cast<LoadingBar*>(getWidgetByName("ProgressBar_effect")); bindTouchEvent("Button_switchAccount", this, toucheventselector(SettingDialog::clickedSwitchAccount)); button_music->addTouchEventListener(this, toucheventselector(SettingDialog::regulateSound)); return true; }
bool LoginLayer::init() { if ( !BaseLayer::init() ) return false; setTouchEnabled(true); CCSize visibleSize = CCDirector::sharedDirector()->getWinSize(); addContentWithJsonFile("UI4Login.ExportJson"); _msg = static_cast<Label*>(getWidgetByName("Label_msg")); _list = static_cast<ListView*>(getWidgetByName("ListView_list")); CCSize size = CCSize(450, 85); _account = CCEditBox::create(size,CCScale9Sprite::createWithSpriteFrameName("input_login.png")); _password = CCEditBox::create(size,CCScale9Sprite::createWithSpriteFrameName("input_login.png")); _account->setPosition(ccp(visibleSize.width/2,visibleSize.height/2 + 68)); _password->setPosition(ccp(_account->getPositionX(),_account->getPositionY()-105)); ccColor3B color = {147,140,115}; _account->setFont("TrebuchetMS-Bold",30); _account->setFontColor(color); _account->setPlaceholderFontColor(color); _account->setPlaceHolder("联众账号"); _account->setMaxLength(19); _account->setSelected(true); _account->setReturnType(kKeyboardReturnTypeDone); _password->setFont("TrebuchetMS-Bold",30); _password->setFontColor(color); _password->setPlaceholderFontColor(color); _password->setPlaceHolder("密码"); _password->setMaxLength(15); _password->setInputFlag(kEditBoxInputFlagPassword); _password->setInputMode(kEditBoxInputModeSingleLine); _password->setZOrder(-1); _uilayer->addChild(_account); _uilayer->addChild(_password); _up = Button::create(); _down = Button::create(); _up->loadTextures("button_up.png", "", "",UI_TEX_TYPE_PLIST); _down->loadTextures("button_down.png", "", "",UI_TEX_TYPE_PLIST); CCPoint point = ccp(_account->getContentSize().width - 40, _account->getContentSize().height/2); _up->setPosition(point); _down->setPosition(point); UILayer* layer = UILayer::create(); layer->addWidget(_down); layer->addWidget(_up); _account->addChild(layer); _list->setAnchorPoint(ccp(0, 1)); _list->setItemModel(GUIReader::shareReader()->widgetFromJsonFile("UI4ItemAccount.ExportJson")); _list->addEventListenerListView(this, listvieweventselector(LoginLayer::onListViewEvent)); bindTouchEvent("btn_login", this, toucheventselector(LoginLayer::onClickedLogin)); bindTouchEvent("btn_register", this, toucheventselector(LoginLayer::onClickedRegister)); _up->addTouchEventListener(this, toucheventselector(LoginLayer::onClickedUp)); _down->addTouchEventListener(this, toucheventselector(LoginLayer::onClickedDown)); setAccountAndPwd(); UserAccountService userAccountService; userAccountService.createTable(); toggleAccouts(false); return true; }
void UIWarone::init() { UILayout::init(); m_TenTime=static_cast<StaticImage*>(getWidgetByName("moshi1/shijian")); m_DigitTime=static_cast<StaticImage*>(getWidgetByName("moshi1/shijian2")); ///指示哪里有敌人出现的旋转按钮 m_pRotateImage=new RotateImage("WarModeone_Enemey_Dir","youxi_fangxiang.png"); registerWidget(m_pRotateImage); m_ScoreImage[0]=static_cast<StaticImage*>(getWidgetByName("moshi1/moshi1xiaoshuzi0.")); m_ScoreImage[1]=static_cast<StaticImage*>(getWidgetByName("moshi1/moshi1xiaoshuzi0")); m_ScoreImage[2]=static_cast<StaticImage*>(getWidgetByName("moshi1/moshi1xiaoshuzi8")); m_ScoreImage[3]=static_cast<StaticImage*>(getWidgetByName("moshi1/moshi1xiaoshuzi5")); m_ScoreImage[4]=static_cast<StaticImage*>(getWidgetByName("moshi1/moshi1xiaoshuzi9")); return ; ///暂停按钮 /*/ m_PauseButton=new ImageButton("WarModeone_PauseButton","youxi_zhanting_release.png","youxi_zhanting_press.png"); registerWidget(m_PauseButton); m_PauseButton->setHorizontalAlignment(Ogre::GHA_LEFT); m_PauseButton->setVerticalAlignment(Ogre::GVA_TOP); m_PauseButton->setLeft(32); m_PauseButton->setTop(32); m_PauseButton->setWidth(80); m_PauseButton->setHeight(80); ///中间准心 ///准心 m_FirePoint=new StaticImage("WarModeone_FirePoint","youxi_zhunxin.png"); registerWidget(m_FirePoint); m_FirePoint->setLeft(m_FirePoint->getWidth()*(-0.5f)); m_FirePoint->setTop(m_FirePoint->getHeight()*(-0.5f)); ///创建记时图标 m_HundredTime=new StaticImage("WarModeone_Hundred","jieshu_shuzi_0.png"); m_HundredTime->setVerticalAlignment(Ogre::GVA_TOP); m_HundredTime->setHorizontalAlignment(Ogre::GHA_RIGHT); m_HundredTime->setWidth(64); m_HundredTime->setHeight(64); m_HundredTime->setLeft(-64*3); registerWidget(m_HundredTime); //m_TenTime; m_TenTime=new StaticImage("WarModeone_Ten","jieshu_shuzi_0.png"); m_TenTime->setVerticalAlignment(Ogre::GVA_TOP); m_TenTime->setHorizontalAlignment(Ogre::GHA_RIGHT); m_TenTime->setWidth(64); m_TenTime->setHeight(64); m_TenTime->setLeft(-64*2); registerWidget(m_TenTime); //m_DigitTime; m_DigitTime=new StaticImage("WarModeone_Digit","jieshu_shuzi_0.png"); m_DigitTime->setVerticalAlignment(Ogre::GVA_TOP); m_DigitTime->setHorizontalAlignment(Ogre::GHA_RIGHT); m_DigitTime->setWidth(64); m_DigitTime->setHeight(64); m_DigitTime->setLeft(-64); registerWidget(m_DigitTime); //*/ }