bool SportLayer::initWidgets4PanelSport(Layout* _sportLay) { bool bRet = false; do { //btn back UIWidget* bgSport = _sportLay->getChildByName("bg_sport"); UITextButton* txtBtnSportBack = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_back")); txtBtnSportBack->addReleaseEvent(this, coco_releaseselector(SportLayer::closeBtnCallBack)); //btn rule UITextButton* txtBtnSportRule = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_rule")); txtBtnSportRule->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportRule->setWidgetTag(sportRuleBtnTag); //btn start UITextButton* txtBtnSportStart = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_start")); txtBtnSportStart->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportStart->setWidgetTag(sportStartBtnTag); //btn top UITextButton* txtBtnSportTop = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_top")); txtBtnSportTop->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportTop->setWidgetTag(sportTopBtnTag); //btn clear UITextButton* txtBtnSportClear = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_clear")); txtBtnSportClear->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportClear->setWidgetTag(sportClearBtnTag); //btn sport reward obtain UIWidget* bgSportReward = bgSport->getChildByName("bg_sport_reward"); UITextButton* txtBtnRewardObtain = dynamic_cast<UITextButton*>(bgSportReward->getChildByName("txtBtn_reward_obtain")); txtBtnRewardObtain->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnRewardObtain->setWidgetTag(sportRewardObtainBtnTag); //btn sport player seat invite UIWidget* bgSportPlayerSeat = bgSport->getChildByName("bg_sport_player_seat"); UIButton* txtBtnSeatInvite = dynamic_cast<UIButton*>(bgSportPlayerSeat->getChildByName("btn_seat_invite")); txtBtnSeatInvite->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSeatInvite->setWidgetTag(sportPlayerSeatInivteBtnTag); bRet = true; } while (0); return bRet; }
void GeneralGroupLogic::onEnter() { CCNode::onEnter(); // Create general buttons in game. for (UINT i = 0; i < m_generalData.size(); ++i) { UIButton* pButton = UIButton::create(); pButton->setWidgetTag(static_cast<int>(i)); pButton->setPosition(ccp(VisibleRect::right().x - 10, 30 * (1 + i) + 50)); pButton->setTouchEnable(true); // Set relationship between these picture with generalType. EGeneralType type = m_generalData[i]; pButton->setTextures(NormalPng[type], SelectedPng[type], DisablePng[type]); pButton->addReleaseEvent(this, coco_releaseselector(GeneralGroupLogic::GeneralBottonClicked)); pButton->addPushDownEvent(this, coco_releaseselector(GeneralGroupLogic::GeneralBottonPushDown)); pButton->setScale(0.5f); UiManager::Singleton().AddChildWidget(pButton); } }
bool ShopLayer::init() { bool bRet = false; do { CC_BREAK_IF(!CCLayer::init()); m_Mediator = NULL; m_buyNum = 1; m_onePri = 5000; m_curTapMenu = SHOP_LAYOUT_TAG_TEJIA; m_pUILayer = UILayer::create(); m_pUILayer->setTouchPriority(-200); m_pUILayer->scheduleUpdate(); addChild(m_pUILayer); Layout* lay; lay = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile("ui/ShopUI/ShopUI.json")); m_pUILayer->addWidget(lay); m_layerLayout = dynamic_cast<Layout*>(lay->getChildByName("layerPanel")); m_buyLayout = dynamic_cast<Layout*>(lay->getChildByName("buyRootPanel")); UIButton* returnBtn1 = dynamic_cast<UIButton*>(m_buyLayout->getChildByName("returnBtn")); returnBtn1->addReleaseEvent(this, coco_releaseselector(ShopLayer::closeBtnDlgCallBack)); UIScrollView* scroV = dynamic_cast<UIScrollView*>(m_layerLayout->getChildByName("ScrollView")); // UIScrollViewP* scroV = dynamic_cast<UIScrollViewP*>(m_layerLayout->getChildByName("ScrollView")); // UIImageView* spr = dynamic_cast<UIImageView*>(m_layerLayout->getChildByName("slideImge")); // CCSize a = scroV->getInnerContainerSize(); // CCSize b =scroV->getSize(); // float scale = b.height/a.height; // spr->setScaleY(scale); // scroV->setSlideSprite(spr,scale); for (int i = 0; i < 8; i++) { UIButton* scroPanel = dynamic_cast<UIButton*>(scroV->getChildByName(CCString::createWithFormat("Panel_%d", i)->getCString())); scroPanel->addReleaseEvent(this, coco_releaseselector(ShopLayer::scroCallBack)); } UIButton* returnBtn = dynamic_cast<UIButton*>(m_layerLayout->getChildByName("returnBtn")); returnBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::closeBtnCallBack)); UIButton* payBtn = dynamic_cast<UIButton*>(m_layerLayout->getChildByName("payBtn")); payBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::payBtnCallBack)); UIButton* subBtn = dynamic_cast<UIButton*>(m_buyLayout->getChildByName("subBtn")); subBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::subBtnCallBack)); UIButton* addBtn = dynamic_cast<UIButton*>(m_buyLayout->getChildByName("addBtn")); addBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::addBtnCallBack)); Layout* buyNumPanel = dynamic_cast<Layout*>(m_buyLayout->getChildByName("buyNumPanel")); buyNumPanel->addReleaseEvent(this,coco_releaseselector(ShopLayer::callForNumInput)); m_buyNumLabel = dynamic_cast<UILabel*>(buyNumPanel->getChildByName("Label")); m_totalPriLabel = dynamic_cast<UILabel*>(m_buyLayout->getChildByName("totalPriLabel")); m_onePriLabel = dynamic_cast<UILabel*>(m_buyLayout->getChildByName("onePriLabel")); UITextButton* buyBtn = dynamic_cast<UITextButton*>(m_buyLayout->getChildByName("buyBtn")); buyBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::buyBtnCallBack)); Layout* tapbtn_panel = dynamic_cast<Layout*>(m_layerLayout->getChildByName("tapbtn_Panel")); tapbtn_panel->setWidgetTag(SHOP_LAYOUT_TAG_ROOT); UIButton* equipBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("equipBtn")); equipBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack)); equipBtn->setWidgetTag(SHOP_LAYOUT_TAG_EQUIP); UIButton* tejiaBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("tejiaBtn")); tejiaBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack)); tejiaBtn->setWidgetTag(SHOP_LAYOUT_TAG_TEJIA); tejiaBtn->disable(); UIButton* diamondBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("diamondBtn")); diamondBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack)); diamondBtn->setWidgetTag(SHOP_LAYOUT_TAG_DIAMOND); UIButton* yaoshuiBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("yaoshuiBtn")); yaoshuiBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack)); yaoshuiBtn->setWidgetTag(SHOP_LAYOUT_TAG_YAOSHUI); UIButton* otherBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("otherBtn")); otherBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack)); otherBtn->setWidgetTag(SHOP_LAYOUT_TAG_OTHER); bRet = true; } while (0); return bRet; }