。h文件
#ifndef _NF_RolE_SELECT_SCENE_head_#define _NF_RolE_SELECT_SCENE_head_#include "../publicdef/PublicDef.h"/************************************************************************//*人物选择层 *//************************************************************************/class CNFRoleSelectLayer : public cclayer{protected: //标签 enum { enTagstudioMainUiLayer,enTagRole1,enTagRole2,enTagRole3,}; int m_nRoleID; //角色ID 1.鸣人 2.小樱 3.佐助 int m_nRelaseRoleID; //解锁角色ID 1.鸣人 2.小樱 3.佐助public: static CNFRoleSelectLayer * CreateLayer(); static CCScene * scene(); voID OnGameStartPage(CCObject *pSender,touchEventType type); //开始游戏 voID OnRoleSelect(CCObject *pSender,touchEventType type); //选择人物 voID OnFollowSelect(CCObject *pSender,touchEventType type); //选择随从 voID OnCancelFollowSelect(CCObject *pSender,touchEventType type); //取消随从 voID OnBack(CCObject *pSender,touchEventType type); //返回登录 voID OnShowReleaseDlg(CCObject *pSender,touchEventType type); //显示解锁对话框 voID OnHIDeReleaseDlg(CCObject *pSender,touchEventType type); //隐藏解锁对话框 voID OnBtnSureRelease(CCObject *pSender,touchEventType type); //确定解锁protected: virtual bool init(); };#endif
.cpp文件
#include "NFRoleSelectLayer.h"#include "NFTownScene.h"#include "NFLoginScene.h"#include "datamanager/NFServerDataManager.h"/************************************************************************//*人物选择层<span > </span>*//************************************************************************/CCScene * CNFRoleSelectLayer::scene(){<span > </span>do<span > </span>{<span > </span>CCScene* pScene = CCScene::create();<span > </span>CC_BREAK_IF(pScene==NulL);<span > </span>CNFRoleSelectLayer* pLayer = CNFRoleSelectLayer::CreateLayer();<span > </span>CC_BREAK_IF(pLayer==NulL);<span > </span>pScene->addChild(pLayer);<span > </span>return pScene;<span > </span>} while (false);<span > </span>cclog("Fun CNFRoleSelectLayer::scene Error!");<span > </span>return NulL;}CNFRoleSelectLayer * CNFRoleSelectLayer::CreateLayer(){<span > </span>CNFRoleSelectLayer *pRet = new CNFRoleSelectLayer();<span > </span>if (pRet && pRet->init())<span > </span>{<span > </span>pRet->autorelease();<span > </span>return pRet;<span > </span>}<span > </span>cclog("Fun CNFRoleSelectLayer::CreateLayer Error!");<span > </span>delete pRet;<span > </span>pRet = NulL;<span > </span>return NulL;}bool CNFRoleSelectLayer::init(){<span > </span>do<span > </span>{<span > </span>//初始化父类<span > </span>CC_BREAK_IF(cclayer::init()==false);<span > </span>m_nRoleID = 0;<span > </span>m_nRelaseRoleID = 0;<span > </span>//创建主场景UI层<span > </span>UILayer* pUiLayer = UILayer::create();<span > </span>CC_BREAK_IF(pUiLayer==NulL);<span > </span>//-------------------加入主场景UI----------------------------<span > </span>UILayout *pBg = dynamic_cast<UILayout*><span > </span>(GUIReader::shareReader()->WidgetFromJsonfile("Character_Select_Bg_NF.Json"));<span > </span>CC_BREAK_IF(pBg==NulL);<span > </span>addChild(pBg,enZOrderBack);<span > </span>pBg->setSize(getContentSize());<span > </span>UILayout *pCharacter_Select = dynamic_cast<UILayout*><span > </span>(GUIReader::shareReader()->WidgetFromJsonfile("Character_Select_NF.Json"));<span > </span>CC_BREAK_IF(pCharacter_Select==NulL);<span > </span>pUiLayer->addWidget(pCharacter_Select);<span > </span>pCharacter_Select->setname("Character_Select_Layer");<span > </span>pCharacter_Select->setSize(getContentSize());<span > </span>CCArmatureDataManager::sharedArmatureDataManager()->addArmaturefileInfo("armature/xiaoyin.ExportJson");<span > </span>CCArmatureDataManager::sharedArmatureDataManager()->addArmaturefileInfo("armature/NewProject.ExportJson");<span > </span>CCArmatureDataManager::sharedArmatureDataManager()->addArmaturefileInfo("armature/minren1.ExportJson");<span > </span>//设置开始游戏回调<span > </span>UIbutton* pBtn_Start_Game = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("Btn_Start_Game"));<span > </span>CC_BREAK_IF(pBtn_Start_Game==NulL);<span > </span>pBtn_Start_Game->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnGameStartPage));<span > </span>//读取角色信息<span > </span>CNFServerRoleSelectInfoVec RoleSelectInfoVec;<span > </span>CNFServerDataManager::SharedData()->GetRoleSelectInfo(RoleSelectInfoVec);<span > </span>CNFServerRoleSelectInfoVec::iterator itRole=RoleSelectInfoVec.begin();<span > </span>char cname[3][256]={"minren1","xiaoyin","NewProject"};<span > </span>for (int i=0;itRole!=RoleSelectInfoVec.end();itRole++,i++)<span > </span>{<span > </span>UIWidget* pChar=dynamic_cast<UIWidget*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString()));<span > </span>CC_BREAK_IF(pChar==NulL);<span > </span>UIbutton* pBtn_Main_Role = dynamic_cast<UIbutton*>(pChar->getChildByname("Btn_Main_Role"));<span > </span>CC_BREAK_IF(pBtn_Main_Role==NulL);<span > </span>pBtn_Main_Role->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnRoleSelect));<span > </span>pBtn_Main_Role->setEnabled(false);<span > </span>UIbutton* pBtnCancel_Follow = dynamic_cast<UIbutton*>(pChar->getChildByname("Btn_Cancel_Follow"));<span > </span>CC_BREAK_IF(pBtnCancel_Follow==NulL);<span > </span>pBtnCancel_Follow->setEnabled(false);<span > </span>pBtnCancel_Follow->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnCancelFollowSelect));<span > </span>UIbutton* pBtnFollow = dynamic_cast<UIbutton*>(pChar->getChildByname("Btn_Follow"));<span > </span>CC_BREAK_IF(pBtnFollow==NulL);<span > </span>pBtnFollow->setEnabled(false);<span > </span>pBtnFollow->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnFollowSelect));<span > </span>CCArmature *pRole = CCArmature::create(cname[i]);<span > </span>CC_BREAK_IF(pRole==NulL);<span > </span>pRole->setposition(ccp(pChar->getpositionX()+SCREEN_WIDTH/2,pChar->getpositionY()-100));<span > </span>pRole->setAnchorPoint(ccp(pRole->getAnchorPoint().x,0));<span > </span>pRole->setScale(1.5f);<span > </span>pRole->getAnimation()->play("hold",-1,10000);<span > </span>addChild(pRole,enZOrderFront,enTagRole1+i);<span > </span>UIbutton* pBtn_Release_Lock = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Release_Lock"));<span > </span>CC_BREAK_IF(pBtn_Release_Lock==NulL);<span > </span>pBtn_Release_Lock->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnShowReleaseDlg));<span > </span>if (itRole->nState==0)//空闲<span > </span>{<span > </span>pBtn_Release_Lock->setEnabled(false);<span > </span>pBtn_Main_Role->setEnabled(true);<span > </span>pBtn_Main_Role->setVisible(true);<span > </span>pBtnFollow->setEnabled(true);<span > </span>pBtnFollow->setVisible(true);<span > </span>}<span > </span>if (itRole->nState==1)//出战<span > </span>{<span > </span>pBtn_Release_Lock->setEnabled(false);<span > </span>pBtn_Main_Role->setEnabled(false);<span > </span>pBtn_Main_Role->setVisible(false);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("Select_Main_Role_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(true);<span > </span>pBtn_Select_img->setposition(pChar->getposition());<span > </span>pBtn_Start_Game->setVisible(true);<span > </span>m_nRoleID=itRole->nRoleID;<span > </span>}<span > </span>if (itRole->nState==2)//助战<span > </span>{<span > </span>pBtn_Release_Lock->setEnabled(false);<span > </span>pBtn_Main_Role->setEnabled(true);<span > </span>pBtn_Main_Role->setVisible(true);<span > </span>pBtnCancel_Follow->setEnabled(true);<span > </span>pBtnCancel_Follow->setVisible(true);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pChar->getChildByname("Select_Follow_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(true);<span > </span>}<span > </span>}<span > </span>//设置返回开始界面回调<span > </span>UIbutton* pBtn_Return = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("Btn_Return"));<span > </span>CC_BREAK_IF(pBtn_Return==NulL);<span > </span>pBtn_Return->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnBack));<span > </span>//隐藏解锁对话框<span > </span>UIImageVIEw *pReleaseDlg = dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("ReleaseDlg"));<span > </span>CC_BREAK_IF(pReleaseDlg==NulL);<span > </span>pReleaseDlg->setEnabled(false);<span > </span>pReleaseDlg->setVisible(false);<span > </span>UIbutton *pCloseDlg=dynamic_cast<UIbutton*>(pReleaseDlg->getChildByname("Btn_Close"));<span > </span>CC_BREAK_IF(pCloseDlg==NulL);<span > </span>pCloseDlg->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnHIDeReleaseDlg));<span > </span>UIbutton *pBtn_Sure=dynamic_cast<UIbutton*>(pReleaseDlg->getChildByname("Btn_Sure"));<span > </span>CC_BREAK_IF(pBtn_Sure==NulL);<span > </span>pBtn_Sure->addtouchEventListener(this,toucheventselector(CNFRoleSelectLayer::OnBtnSureRelease));<span > </span>addChild(pUiLayer,enTagstudioMainUiLayer);<span > </span>return true;<span > </span>} while (false);<span > </span>cclog("Fun CNFRoleSelectLayer::init Error!");<span > </span>return false;}voID CNFRoleSelectLayer::OnGameStartPage( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>//跳转到城镇<span > </span>CCScene * pScene = CNFTownScene::CreatetownScene(1,m_nRoleID);<span > </span>CC_BREAK_IF(pScene==NulL);<span > </span>CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1.f,pScene));<span > </span><span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnGameStartPage Error");}voID CNFRoleSelectLayer::OnRoleSelect( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>UILayer* pMainUiLayer = dynamic_cast<UILayer*>(getChildByTag(enTagstudioMainUiLayer));<span > </span>CC_BREAK_IF(pMainUiLayer==NulL);<span > </span>UILayout *pCharacter_Select = dynamic_cast<UILayout*><span > </span>(pMainUiLayer->getWidgetByname("Character_Select_Layer"));<span > </span>CC_BREAK_IF(pCharacter_Select==NulL);<span > </span>for (int i=0;i<3;i++)<span > </span>{<span > </span>UIbutton* pBtn_Release_Lock = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Release_Lock"));<span > </span>CC_BREAK_IF(pBtn_Release_Lock==NulL);<span > </span>if(pBtn_Release_Lock->isEnabled())continue;<span > </span>UIbutton* pBtnSelect = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Main_Role"));<span > </span>CC_BREAK_IF(pBtnSelect==NulL);<span > </span>pBtnSelect->setVisible(true);<span > </span>pBtnSelect->setEnabled(true);<span > </span>UIbutton* pBtnFollow = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Follow"));<span > </span>CC_BREAK_IF(pBtnFollow==NulL);<span > </span>pBtnFollow->setVisible(true);<span > </span>pBtnFollow->setEnabled(true);<span > </span>UIbutton* pBtnCancel_Follow = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Cancel_Follow"));<span > </span>CC_BREAK_IF(pBtnCancel_Follow==NulL);<span > </span>pBtnCancel_Follow->setEnabled(false);<span > </span>pBtnCancel_Follow->setVisible(false);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Select_Follow_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(false);<span > </span>}<span > </span>UIbutton* pBtn = dynamic_cast<UIbutton*>(pSender);<span > </span>CC_BREAK_IF(pBtn==NulL);<span > </span>pBtn->setVisible(false);<span > </span><span > </span>UIWidget* pUiLayer = dynamic_cast<UIWidget*>(pBtn->getParent()->getParent());<span > </span>CC_BREAK_IF(pUiLayer==NulL);<span > </span>UIWidget* pChar = dynamic_cast<UIWidget*>(pBtn->getParent());<span > </span>CC_BREAK_IF(pChar==NulL);<span > </span>//判断选择的那个角色<span > </span>if (strcmp("Char_1",pChar->getname())==0)<span > </span>m_nRoleID = 1;<span > </span>//鸣人<span > </span>else if (strcmp("Char_2",pChar->getname())==0)<span > </span>m_nRoleID = 2;<span > </span>//小樱<span > </span>else if (strcmp("Char_3",pChar->getname())==0)<span > </span>m_nRoleID = 3;<span > </span>//佐助<span > </span>//cclog("%d",m_nRoleID);<span > </span>for (int i=0;i<3;i++)<span > </span>{<span > </span>CCArmature *pRole = dynamic_cast<CCArmature*>(getChildByTag(i+enTagRole1));<span > </span>CC_BREAK_IF(pRole==NulL);<span > </span>if (pRole->getpositionX()-SCREEN_WIDTH/2==pChar->getpositionX())<span > </span>{<span > </span><span > </span><span > </span>if (strcmp("Char_1",pChar->getname())==0)<span > </span>pRole->getAnimation()->play("skill_2",10000);<span > </span>//鸣人<span > </span>else if (strcmp("Char_2",pChar->getname())==0)<span > </span>pRole->getAnimation()->play("skill_3",10000);<span > </span>//小樱<span > </span>else if (strcmp("Char_3",pChar->getname())==0)<span > </span>pRole->getAnimation()->play("skill_5",10000);<span > </span>//佐助<span > </span>}<span > </span>else<span > </span>{<span > </span>pRole->getAnimation()->play("hold",10000);<span > </span>}<span > </span>}<span > </span>UIbutton* pBtnFollowSelect = dynamic_cast<UIbutton*>(pChar->getChildByname("Btn_Follow"));<span > </span>CC_BREAK_IF(pBtnFollowSelect==NulL);<span > </span>pBtnFollowSelect->setEnabled(false);<span > </span>pBtnFollowSelect->setVisible(false);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pUiLayer->getChildByname("Select_Main_Role_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(true);<span > </span>pBtn_Select_img->setposition(pChar->getposition());<span > </span>//设置开始游戏回调<span > </span>UIbutton* pBtn_Start_Game = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("Btn_Start_Game"));<span > </span>CC_BREAK_IF(pBtn_Start_Game==NulL);<span > </span>pBtn_Start_Game->setVisible(true);<span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnRoleSelect Error");}voID CNFRoleSelectLayer::OnBack( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>//跳转到服务器选择界面<span > </span>CCScene * pScene = CNFLoginScene::scene();<span > </span>CC_BREAK_IF(pScene==NulL);<span > </span>CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1.f,pScene));<span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnBack Error");}voID CNFRoleSelectLayer::OnFollowSelect( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>//UILayer* pMainUiLayer = dynamic_cast<UILayer*>(getChildByTag(enTagstudioMainUiLayer));<span > </span>//CC_BREAK_IF(pMainUiLayer==NulL);<span > </span>//UILayout *pCharacter_Select = dynamic_cast<UILayout*><span > </span>(pMainUiLayer->getWidgetByname("Character_Select_Layer"));<span > </span>//CC_BREAK_IF(pCharacter_Select==NulL);<span > </span>//for (int i=0;i<3;i++)<span > </span>//{<span > </span>//<span > </span>UIbutton* pBtnSelect = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Main_Role"));<span > </span>//<span > </span>CC_BREAK_IF(pBtnSelect==NulL);<span > </span>//<span > </span>pBtnSelect->setVisible(true);<span > </span>//<span > </span>UIbutton* pBtnFollow = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",i+1)->getCString())->getChildByname("Btn_Follow"));<span > </span>//<span > </span>CC_BREAK_IF(pBtnFollow==NulL);<span > </span>//<span > </span>pBtnFollow->setVisible(true);<span > </span>//}<span > </span>UIbutton* pBtn = dynamic_cast<UIbutton*>(pSender);<span > </span>CC_BREAK_IF(pBtn==NulL);<span > </span>pBtn->setVisible(false);<span > </span>pBtn->setEnabled(false);<span > </span>UIWidget* pChar = dynamic_cast<UIWidget*>(pBtn->getParent());<span > </span>CC_BREAK_IF(pChar==NulL);<span > </span>UIbutton* pBtn_Cancel_Follow = dynamic_cast<UIbutton*>(pChar->getChildByname("Btn_Cancel_Follow"));<span > </span>CC_BREAK_IF(pBtn_Cancel_Follow==NulL);<span > </span>pBtn_Cancel_Follow->setVisible(true);<span > </span>pBtn_Cancel_Follow->setEnabled(true);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pChar->getChildByname("Select_Follow_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(true);<span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnFollowSelect Error");}voID CNFRoleSelectLayer::OnCancelFollowSelect( CCObject *pSender,i+1)->getCString())->getChildByname("Btn_Follow"));<span > </span>//<span > </span>CC_BREAK_IF(pBtnFollow==NulL);<span > </span>//<span > </span>pBtnFollow->setVisible(true);<span > </span>//}<span > </span>UIbutton* pBtn = dynamic_cast<UIbutton*>(pSender);<span > </span>CC_BREAK_IF(pBtn==NulL);<span > </span>pBtn->setVisible(false);<span > </span>pBtn->setEnabled(false);<span > </span>UIWidget* pChar = dynamic_cast<UIWidget*>(pBtn->getParent());<span > </span>CC_BREAK_IF(pChar==NulL);<span > </span>UIbutton* pBtn_Follow = dynamic_cast<UIbutton*>(pChar->getChildByname("Btn_Follow"));<span > </span>CC_BREAK_IF(pBtn_Follow==NulL);<span > </span>pBtn_Follow->setVisible(true);<span > </span>pBtn_Follow->setEnabled(true);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pChar->getChildByname("Select_Follow_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(false);<span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnCancelFollowSelect Error");}voID CNFRoleSelectLayer::OnShowReleaseDlg( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>UILayer* pMainUiLayer = dynamic_cast<UILayer*>(getChildByTag(enTagstudioMainUiLayer));<span > </span>CC_BREAK_IF(pMainUiLayer==NulL);<span > </span>UILayout *pCharacter_Select = dynamic_cast<UILayout*><span > </span>(pMainUiLayer->getWidgetByname("Character_Select_Layer"));<span > </span>CC_BREAK_IF(pCharacter_Select==NulL);<span > </span>UIbutton* pBtn = dynamic_cast<UIbutton*>(pSender);<span > </span>CC_BREAK_IF(pBtn==NulL);<span > </span>UIWidget* pChar = dynamic_cast<UIWidget*>(pBtn->getParent());<span > </span>CC_BREAK_IF(pChar==NulL);<span > </span>//隐藏解锁对话框<span > </span>UIImageVIEw *pReleaseDlg = dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("ReleaseDlg"));<span > </span>CC_BREAK_IF(pReleaseDlg==NulL);<span > </span>pReleaseDlg->setEnabled(true);<span > </span>pReleaseDlg->setVisible(true);<span > </span>UILabel* pCharname = dynamic_cast<UILabel*>(pChar->getChildByname("Char_Info")->getChildByname("name_Lable"));<span > </span>CC_BREAK_IF(pCharname==NulL);<span > </span>UILabel *pname_Lable = dynamic_cast<UILabel*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("ReleaseDlg")->getChildByname("name_Lable"));<span > </span>CC_BREAK_IF(pname_Lable==NulL);<span > </span>pname_Lable->setText(pCharname->getStringValue());<span > </span><span > </span>//判断选择的那个角色<span > </span>if (strcmp("Char_1",pChar->getname())==0)<span > </span>//鸣人<span > </span>{<span > </span>m_nRelaseRoleID=1;<span > </span>}<span > </span>else if (strcmp("Char_2",pChar->getname())==0)<span > </span>//小樱<span > </span>{<span > </span>m_nRelaseRoleID=2;<span > </span>}<span > </span>else if (strcmp("Char_3",pChar->getname())==0)<span > </span>//佐助<span > </span>{<span > </span>m_nRelaseRoleID=3;<span > </span>}<span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnShowReleaseDlg Error");}voID CNFRoleSelectLayer::OnBtnSureRelease( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>if(m_nRelaseRoleID==0)return;<span > </span>UILayer* pMainUiLayer = dynamic_cast<UILayer*>(getChildByTag(enTagstudioMainUiLayer));<span > </span>CC_BREAK_IF(pMainUiLayer==NulL);<span > </span>UILayout *pCharacter_Select = dynamic_cast<UILayout*><span > </span>(pMainUiLayer->getWidgetByname("Character_Select_Layer"));<span > </span>CC_BREAK_IF(pCharacter_Select==NulL);<span > </span>//隐藏解锁对话框<span > </span>UIImageVIEw *pReleaseDlg = dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("ReleaseDlg"));<span > </span>CC_BREAK_IF(pReleaseDlg==NulL);<span > </span>pReleaseDlg->setEnabled(false);<span > </span>pReleaseDlg->setVisible(false);<span > </span>//读取角色信息<span > </span>CNFServerRoleSelectInfoVec RoleSelectInfoVec;<span > </span>CNFServerDataManager::SharedData()->GetRoleSelectInfo(RoleSelectInfoVec);<span > </span>CNFServerRoleSelectInfoVec::iterator itRole=RoleSelectInfoVec.begin();<span > </span>for (;itRole!=RoleSelectInfoVec.end();itRole++)<span > </span>{<span > </span>if (itRole->nRoleID==m_nRelaseRoleID)<span > </span>{<span > </span>itRole->nState=0;<span > </span>}<span > </span>}<span > </span>CNFServerDataManager::SharedData()->SetRoleSelectInfo(RoleSelectInfoVec);<span > </span>UIbutton* pBtn_Release_Lock = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",m_nRelaseRoleID)->getCString())->getChildByname("Btn_Release_Lock"));<span > </span>CC_BREAK_IF(pBtn_Release_Lock==NulL);<span > </span>pBtn_Release_Lock->setEnabled(false);<span > </span>pBtn_Release_Lock->setVisible(false);<span > </span>UIbutton* pBtnSelect = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",m_nRelaseRoleID)->getCString())->getChildByname("Btn_Main_Role"));<span > </span>CC_BREAK_IF(pBtnSelect==NulL);<span > </span>pBtnSelect->setVisible(true);<span > </span>pBtnSelect->setEnabled(true);<span > </span>UIbutton* pBtnFollow = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",m_nRelaseRoleID)->getCString())->getChildByname("Btn_Follow"));<span > </span>CC_BREAK_IF(pBtnFollow==NulL);<span > </span>pBtnFollow->setVisible(true);<span > </span>pBtnFollow->setEnabled(true);<span > </span>UIbutton* pBtnCancel_Follow = dynamic_cast<UIbutton*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",m_nRelaseRoleID)->getCString())->getChildByname("Btn_Cancel_Follow"));<span > </span>CC_BREAK_IF(pBtnCancel_Follow==NulL);<span > </span>pBtnCancel_Follow->setEnabled(false);<span > </span>pBtnCancel_Follow->setVisible(false);<span > </span>//获取按下图<span > </span>UIImageVIEw* pBtn_Select_img=dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname(CCString::createWithFormat("Char_%d",m_nRelaseRoleID)->getCString())->getChildByname("Select_Follow_img"));<span > </span>CC_BREAK_IF(pBtn_Select_img==NulL);<span > </span>pBtn_Select_img->setVisible(false);<span > </span><span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnHIDeReleaseDlg Error");}voID CNFRoleSelectLayer::OnHIDeReleaseDlg( CCObject *pSender,touchEventType type ){<span > </span>do<span > </span>{<span > </span>switch (type)<span > </span>{<span > </span>case touch_EVENT_ENDED:<span > </span>{<span > </span>UILayer* pMainUiLayer = dynamic_cast<UILayer*>(getChildByTag(enTagstudioMainUiLayer));<span > </span>CC_BREAK_IF(pMainUiLayer==NulL);<span > </span>UILayout *pCharacter_Select = dynamic_cast<UILayout*><span > </span>(pMainUiLayer->getWidgetByname("Character_Select_Layer"));<span > </span>CC_BREAK_IF(pCharacter_Select==NulL);<span > </span>//隐藏解锁对话框<span > </span>UIImageVIEw *pReleaseDlg = dynamic_cast<UIImageVIEw*>(pCharacter_Select->getChildByname("Main_Ui")->getChildByname("ReleaseDlg"));<span > </span>CC_BREAK_IF(pReleaseDlg==NulL);<span > </span>pReleaseDlg->setEnabled(false);<span > </span>}break;<span > </span>default:<span > </span>break;<span > </span>}<span > </span>return;<span > </span>} while (false);<span > </span>cclog("CNFRoleSelectLayer::OnHIDeReleaseDlg Error");}个人博客 www.sundaboke.com总结
以上是内存溢出为你收集整理的分析Cocos2d-x横版ACT手游源代码 3、人物选择界面全部内容,希望文章能够帮你解决分析Cocos2d-x横版ACT手游源代码 3、人物选择界面所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)