void LayerChatWindow::OnEmoClick( CCObject* pSender, TouchEventType type ) { UIButton* btn = dynamic_cast<UIButton*>(pSender); if( type == TOUCH_EVENT_ENDED ){ CCLOG("OnEmoClick button tag: %d", btn->getTag()); txtChat->setText( CCString::createWithFormat("%s(%d)", txtChat->getStringValue(), btn->getTag())->getCString() ); } }
void Scene_GameItem::itemBtnCallBack(cocos2d::CCObject *object) { UIButton* btn = (UIButton*)object; UIImageView* img; //通过游戏的道具信息获取道具价钱. sItemData* itemData = CGameInfoMan::sharedInstance().getItemDate(GameShare_Global::shareGlobal()->gameType, btn->getTag()); UILabel* itemInfo = dynamic_cast<UILabel*>(ul->getWidgetByName("Label_591")); switch (btn->getTag()) { case Btn_1: img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_1")); break; case Btn_2: img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_2")); break; case Btn_3: img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_3")); break; case Btn_4: img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_4")); break; default: break; } if (img->isVisible()) { img->setVisible(false); if (itemData) { CCString infoStr; infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str()); itemInfo->setText(infoStr.getCString()); needGold -= itemData->CurrencyValue; } }else{ img->setVisible(true); if (itemData) { CCString infoStr; infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str()); itemInfo->setText(infoStr.getCString()); needGold += itemData->CurrencyValue; if (CPlayerInfoMan::sharedInstance().getPlayerInfo().nMoney < needGold) { GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); needGold -= itemData->CurrencyValue; alertUl->setText(GET_STRING_CSV(1010000021)); this->addChild(alertUl,1); img->setVisible(false); } } } this->setItemByTag(btn->getTag()); }
void GameLayer_GoldMarket::sureBuyCallback(cocos2d::CCObject *pSender) { UIButton* btn = (UIButton*)pSender; switch (btn->getTag()) { case Buy_0: { CPlayerInfoMan::sharedInstance().RequestDiamondToGold(DiamondToGold_1); // GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); // alertUl->setText(GET_STRING_CSV(1010000016)); // this->addChild(alertUl); } break; case Buy_1: { CPlayerInfoMan::sharedInstance().RequestDiamondToGold(DiamondToGold_2); // GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); // alertUl->setText(GET_STRING_CSV(1010000016)); // this->addChild(alertUl); } break; case Buy_2: { CPlayerInfoMan::sharedInstance().RequestDiamondToGold(DiamondToGold_3); // GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); // alertUl->setText(GET_STRING_CSV(1010000016)); // this->addChild(alertUl); } break; case Buy_3: { CPlayerInfoMan::sharedInstance().RequestDiamondToGold(DiamondToGold_4); // GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); // alertUl->setText(GET_STRING_CSV(1010000016)); // this->addChild(alertUl); } break; case Buy_4: { CPlayerInfoMan::sharedInstance().RequestDiamondToGold(DiamondToGold_5); // GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); // alertUl->setText(GET_STRING_CSV(1010000016)); // this->addChild(alertUl); } break; default: break; } sureBuyCallEffect(btn->getTag(),1); }
void LayerBaCayAvatar::vaoBanChoi(CCObject *obj,TouchEventType type) { UIButton *abc = (UIButton*)obj; int tag=abc->getTag(); if(type==TOUCH_EVENT_ENDED) if(tag==1) { //yêu cầu làm khách boost::shared_ptr<IRequest> request (new PlayerToSpectatorRequest()); GameServer::getSingleton().getSmartFox()->Send(request); btn_vaochoi->setEnabled(true); btn_dungday->setEnabled(false); //yêu cầu rời game boost::shared_ptr<ISFSObject> params (new SFSObject()); boost::shared_ptr<Room> lastRoom = GameServer::getSingleton().getSmartFox()->LastJoinedRoom(); boost::shared_ptr<IRequest> req (new ExtensionRequest("rqlg", params, lastRoom)); GameServer::getSingleton().getSmartFox()->Send(req); }/// else{ //yêu cầu vào chơi boost::shared_ptr<IRequest> request (new SpectatorToPlayerRequest()); GameServer::getSingleton().getSmartFox()->Send(request); CCLog("da vao"); btn_vaochoi->setEnabled(false); btn_dungday->setEnabled(true); //yêu cầu join game boost::shared_ptr<ISFSObject> params (new SFSObject()); boost::shared_ptr<Room> lastRoom = GameServer::getSingleton().getSmartFox()->LastJoinedRoom(); boost::shared_ptr<IRequest> req2 (new ExtensionRequest("rqjg", params, lastRoom)); GameServer::getSingleton().getSmartFox()->Send(req2); } }
void PromptBox::buttonClicked(CCObject *pSender, TouchEventType eType) { if (eType != TOUCH_EVENT_ENDED) { return; } ::playSound("music/click.ogg"); UIButton *button = dynamic_cast<UIButton*>(pSender) ; int tag = button->getTag() ; switch (tag) { case ButtonTag_Cancel: { removeFromParent(); } break; case ButtonTag_Confirm: { CCDirector::sharedDirector()->end(); } break; default: break; } }
void OnButtonClick_1(void *sender, void*args) { UIButton *button = static_cast<UIButton*>(sender); std::cout << "OnButtonClick_1 : " << button->getTag() << std::endl; button->setPosX(button->getPosX() + 10); }
void Scene_GameItem::equipSuperCallBack(cocos2d::CCObject *object) { UIButton* btn = (UIButton*)object; if (gameLayer_Strong) { gameLayer_Strong = NULL; } gameLayer_Strong = GameLayer_ItemStrong::create(); gameLayer_Strong->setSureCallbackFunc(this, callfuncO_selector(Scene_GameItem::equipBtnCallBack)); CCString equipName = ""; int equipLv = 0; CCString equipValue = ""; CCString equipDetail = ""; CCString equipImg = ""; //获取玩家的这款游戏的强化信息. sMGameStrengthen mStrength; if (int temp = CPlayerInfoMan::sharedInstance().getMStrengthenByGameTag(GameShare_Global::shareGlobal()->gameType, btn->getTag(),mStrength)) { equipLv = mStrength.strengthenlv; equipValue.initWithFormat("x%d", mStrength.currencyValue); equipName.initWithFormat("./CocoStudioResources/GameItemName/%d.png",mStrength.strengthenImg); equipDetail = mStrength.strengthenDetail; equipImg.initWithFormat("./CocoStudioResources/GameStrengthen/%d.png",mStrength.strengthenImg); if (temp == 2) { equipValue = GET_STRING_CSV(1010000025); gameLayer_Strong->setBtnUnClick(); } } CCString str; gameLayer_Strong->setItemInfo(equipDetail.getCString()); gameLayer_Strong->setItemImg(equipImg.getCString()); gameLayer_Strong->setItemLv(equipLv); gameLayer_Strong->setItemName(equipName.getCString()); gameLayer_Strong->setItemCurrency(mStrength.currencyValue); // gameLayer_Strong->setSureCallbackFunc(this, callfuncO_selector(Scene_GameItem::equipBtnCallBack)); gameLayer_Strong->setSureBtnTag(btn->getTag()); gameLayer_Strong->setTag(btn->getTag()); this->addChild(gameLayer_Strong,1); }
void ShopLayer::scroCallBack( CCObject* pSender ) { UIButton* tempPanel = dynamic_cast<UIButton*>(pSender); int temp = tempPanel->getTag(); if (SHOP_LAYOUT_TAG_TEJIA == m_curTapMenu) { updateBuyLayout(pSender,true); } else { updateBuyLayout(pSender,false); } m_layerLayout->setTouchEnable(false,true); m_buyLayout->setVisible(true); m_buyLayout->setTouchEnable(true,true); }
void MailLayer::scroCallBack( CCObject* pSender ) { UIButton* tempPanel = dynamic_cast<UIButton*>(pSender); int temp = tempPanel->getTag(); // UIScrollView* scroV = dynamic_cast<UIScrollView*>(m_mailLayout->getChildByName("ScrollView")); // UIButton* scroPanel[5]; // for (int i = 0; i < 5; i++) // { // scroPanel[i] = dynamic_cast<Layout*>(scroV->getChildByName(CCString::createWithFormat("Panel_%d", i)->getCString())); // scroPanel[i]->setBackGroundColor(ccc3(150,200,255)); // } // // scroPanel[temp % 100]->setBackGroundColor(ccc3(255,20,255)); layerNum = MAILLAYER_TAG_RECEIVE; updateLayer(); }
void ChallengeLayer::buttonClicked(CCObject *pSender, TouchEventType eType) { if (eType != TOUCH_EVENT_ENDED) { return; } ::playSound("music/click.ogg"); UIButton *button = dynamic_cast<UIButton*>(pSender) ; int tag = button->getTag() ; switch (tag) { case ButtonTagStrenthLevel: { CCLOG("nextLevel") ; CCDirector::sharedDirector()->pushScene(StrengthLevelup::scene()); //CCDirector::sharedDirector()->replaceScene(BattleManage::scene(m_br.hero,((m_br.level + 1) > 12?12:(m_br.level + 1) ),false)); // 目前只写了三关的数据 } break; case ButtonTagBackToMain: { CCLOG("backTomain") ; CCDirector::sharedDirector()->replaceScene(GameMainMenu::scene(false)); } break; case ButtonTagReAgain: { CCDirector::sharedDirector()->replaceScene(BattleManage::scene( currentHero,currentLevel,true)); CCLOG("reagain!"); } break; default: break; } }
void Scene_GameItem::equipBtnCallBack(cocos2d::CCObject *object) { UIButton* btn = (UIButton*)object; //获取游戏的强化信息. sMGameStrengthen mStrength; if (CPlayerInfoMan::sharedInstance().getMStrengthenByGameTag(GameShare_Global::shareGlobal()->gameType, btn->getTag(),mStrength)) { int tempGold = CPlayerInfoMan::sharedInstance().getPlayerInfo().nMoney; tempGold = tempGold - mStrength.currencyValue - needGold; if (tempGold < 0) { GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); alertUl->setText(GET_STRING_CSV(1010000021)); alertUl->setSureCallbackFunc(this, callfuncO_selector(Scene_GameItem::equipSuperBtnCanBenClick)); this->addChild(alertUl, 10); return; } CStrengthenMan::sharedInstance().RequestStrengthenLvUp(mStrength.strengthenId, GameShare_Global::shareGlobal()->gameType); } }
void OnClickTest(void *sender, void *arg) { UIButton *button = static_cast<UIButton*>(sender); std::cout << "on ClickText : " << button->getTag() << std::endl; }
void GameLayer_GoldMarket::buyBtnCallback(cocos2d::CCObject *pSender) { UIButton* button = (UIButton*)pSender; GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_Noraml); alertUl->setSureCallbackFunc(this, callfuncO_selector(GameLayer_GoldMarket::sureBuyCallback)); alertUl->setSureBtnTag(button->getTag()); SMoneySysChgTempData* pData; switch (button->getTag()) { case Buy_0: { pData = CMoneyMan::sharedInstance().getChgTempData(DiamondToGold_1); if (pData) { CCString str; str.initWithFormat(GET_STRING_CSV(101000001), pData->ExchangeFromValue,pData->ExchangeToValue); alertUl->setText(str.getCString()); } } break; case Buy_1: //alertUl->setText("确定要用10宝石兑换4500金币吗?"); { pData = CMoneyMan::sharedInstance().getChgTempData(DiamondToGold_2); if (pData) { CCString str; str.initWithFormat(GET_STRING_CSV(101000002), pData->ExchangeFromValue,pData->ExchangeToValue); alertUl->setText(str.getCString()); } } break; case Buy_2: //alertUl->setText("确定要用50宝石兑换1200金币吗?"); { pData = CMoneyMan::sharedInstance().getChgTempData(DiamondToGold_3); if (pData) { CCString str; str.initWithFormat(GET_STRING_CSV(101000003), pData->ExchangeFromValue,pData->ExchangeToValue); alertUl->setText(str.getCString()); } } break; case Buy_3: //alertUl->setText("确定要用100宝石兑换10000金币吗?"); { pData = CMoneyMan::sharedInstance().getChgTempData(DiamondToGold_4); if (pData) { CCString str; str.initWithFormat(GET_STRING_CSV(101000004), pData->ExchangeFromValue,pData->ExchangeToValue); alertUl->setText(str.getCString()); } } break; case Buy_4: //alertUl->setText("确定要用500宝石兑换60000金币吗?"); { pData = CMoneyMan::sharedInstance().getChgTempData(DiamondToGold_5); if (pData) { CCString str; str.initWithFormat(GET_STRING_CSV(101000005), pData->ExchangeFromValue,pData->ExchangeToValue); alertUl->setText(str.getCString()); } } break; default: break; } if (CPlayerInfoMan::sharedInstance().getPlayerInfo().nGem-pData->ExchangeFromValue < 0) { // GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure); //alertUl->setText(GET_STRING_CSV(1010000022)); //this->addChild(alertUl); return; } this->addChild(alertUl); }
void ShoppingLayer::buttonClicked(CCObject *pSender, TouchEventType eType) { if (eType != TOUCH_EVENT_ENDED) { return; } ::playSound("music/click.ogg"); UIButton *button = dynamic_cast<UIButton*>(pSender) ; int tag = button->getTag() ; switch (tag) { case ButtonTag_Buy: { //#if(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32/* || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID*/) // successCallBack(true); // return; //#endif int index = RunningData::getInstance()->getShopping().getIndex(); int catlog = RunningData::getInstance()->getShopping().getCatalog(); //#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // 缺少升至满级的计费点 if(catlog == 1) // 技能 { //savePaycode("4"); //savePaycode("30000852696003"); //savePaycode("30000842303704"); //payID = "004"; // 技能升级 payCode(k_pay_fulllevel, this, Sel_Pay_Event(&ShoppingLayer::successCallBack)); } else if (catlog == 2) // 角色 { if (index == 1) // 黑寡妇 { savePaycode("5"); //savePaycode("30000852696004"); //savePaycode("30000842303705"); payID = "005"; } else if (index == 2) // 擎天柱 { savePaycode("6"); //savePaycode("30000852696005"); //savePaycode("30000842303706"); payID = "006"; } else {//金币补给 savePaycode("2"); //savePaycode("30000852696001"); //savePaycode("30000842303702"); } } else if (catlog == 3) // 补给 { if (index == 0) {//金币补给 payCode(k_pay_gold10000, this, Sel_Pay_Event(&ShoppingLayer::successCallBack)); } else if (index == 1)//必杀 { payCode(k_pay_bisha, this, Sel_Pay_Event(&ShoppingLayer::successCallBack)); } else if(index == 2)//护盾 { payCode(k_pay_hudun, this, Sel_Pay_Event(&ShoppingLayer::successCallBack)); } else if(index == 3)//立即复活 { payCode(k_pay_revieve, this, Sel_Pay_Event(&ShoppingLayer::successCallBack)); } else if(index == 4) { savePaycode("1"); //savePaycode("30000842303701"); payID = "001"; } else if(index == 5) {//土豪金礼包 savePaycode("9"); //激战僵尸 //savePaycode("30000852696008"); //第一版计费 //savePaycode("30000842303709"); payID = "009"; } else if(index == 6) { savePaycode("10"); //savePaycode("30000852696009"); //savePaycode("30000842303710"); payID = "010"; } else { savePaycode("2"); //savePaycode("30000852696001"); //savePaycode("30000842303702"); payID = "002"; } } else { // 默认情况下 savePaycode("2"); //savePaycode("30000852696001"); //savePaycode("30000842303702"); payID = "002"; } // payForProduct(ShoppingLayer::successCallBack); //#endif } break; case ButtonTag_Cancel: { // 失败 ::playSound("music/operationfail.ogg"); CCLOG("ButtonTag_Cancel start!"); int index = RunningData::getInstance()->getShopping().getIndex(); int catlog = RunningData::getInstance()->getShopping().getCatalog(); //if((index == k_rebirth || index == k_unique_kill || index == k_shield) // && catlog == k_supply) //{ // m_failFun(); //} sInstance->showShoppingTip(false); m_failFun(); removeFromParent(); } break; default: break; } CCLog("222222222"); }