Esempio n. 1
0
NS_MAIN_BEGIN

void Mainui::onLoadScene()
{
	setAutoRemoveUnusedTexture(true);
	TuiManager::getInstance()->parseScene(this,"panel_main",PATH_MAIN);

	//注册事件
	CControlView *ctlv = (CControlView*)this->getControl(PANEL_MAIN,CTLV_LEFT);
	ctlv->setOnControlListener(this,ccw_control_selector(Mainui::event_ctlv_left));

	CButton *pBtnOk = (CButton*)this->getControl(PANEL_MAIN,BTN_OK);
	pBtnOk->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_ok));

	CButton *pBtnGo = (CButton*)this->getControl(PANEL_MAIN,BTN_GO);
	pBtnGo->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_go));

	CButton *pShowPhone = (CButton*)this->getControl(PANEL_MAIN, BTN_SHOWPHONE);
	pShowPhone->setOnClickListener(this, ccw_click_selector(Mainui::event_btn_showphone));

	CToggleView *pTgvA = (CToggleView*)this->getControl(PANEL_MAIN, TGV_A);
	pTgvA->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvA_check));

	CToggleView *pTgvB = (CToggleView*)this->getControl(PANEL_MAIN, TGV_B);
	pTgvB->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvB_check));

	MovieView *pMovie = (MovieView*)this->getControl(PANEL_MAIN, MOVIE_TEST);
	map<string, function<void()>> m;
	m["finish"] = bind(&Mainui::event_movie_finish, this);
	pMovie->setCallBack(m);

	//播放骨骼动画(默认不播放)
	Armature *armature = (Armature*)this->getControl(PANEL_MAIN,ARMATURE_BOSS1);
	armature->getAnimation()->play("live",-1,1);
}
Esempio n. 2
0
bool CToggleViewGroupTest::init()
{
	CToggleViewTestSceneBase::init();
	setTitle("CToggleViewGroupTest");
	setDescription("Toggle button in group");

	CToggleView* pToggle1 = CToggleView::create("toggle1_2.png", "toggle1_1.png");
	pToggle1->setOnCheckListener(this, ccw_check_selector(CToggleViewGroupTest::onCheck));
	pToggle1->setPosition(Vec2(200, 450));
	pToggle1->setExclusion(1);
	m_pWindow->addChild(pToggle1);

	CToggleView* pToggle2 = CToggleView::create("toggle1_2.png", "toggle1_1.png");
	pToggle2->setOnCheckListener(this, ccw_check_selector(CToggleViewGroupTest::onCheck));
	pToggle2->setPosition(Vec2(200, 350));
	pToggle2->setExclusion(1);
	m_pWindow->addChild(pToggle2);

	CToggleView* pToggle3 = CToggleView::create("toggle1_2.png", "toggle1_1.png");
	pToggle3->setOnCheckListener(this, ccw_check_selector(CToggleViewGroupTest::onCheck));
	pToggle3->setPosition(Vec2(200, 250));
	pToggle3->setExclusion(1);
	m_pWindow->addChild(pToggle3);

	CLabel* pText1 = CLabel::createWithSystemFont("none","",35);
	pText1->setAnchorPoint(Vec2(0, 0.5));
	pText1->setPosition(Vec2(350, 450));
	pText1->setString("none");
	m_pWindow->addChild(pText1);
	pToggle1->setUserObject(pText1);

	CLabel* pText2 = CLabel::createWithSystemFont("none","",35);
	pText2->setAnchorPoint(Vec2(0, 0.5));
	pText2->setPosition(Vec2(350, 350));
	pText2->setString("none");
	m_pWindow->addChild(pText2);
	pToggle2->setUserObject(pText2);

	CLabel* pText3 = CLabel::createWithSystemFont("none","",35);
	pText3->setAnchorPoint(Vec2(0, 0.5));
	pText3->setPosition(Vec2(350, 250));
	pText3->setString("none");
	m_pWindow->addChild(pText3);
	pToggle3->setUserObject(pText3);


	CToggleView* pToggle4 = CToggleView::create("toggle1_2.png", "toggle1_1.png");
	pToggle4->setPosition(Vec2(700, 250));
	pToggle4->setExclusion(2);
	m_pWindow->addChild(pToggle4);

	CToggleView* pToggle5 = CToggleView::create("toggle1_2.png", "toggle1_1.png");
	pToggle5->setPosition(Vec2(700, 350));
	pToggle5->setExclusion(2);
	m_pWindow->addChild(pToggle5);

	return true;
}
Esempio n. 3
0
void CCommandLayer::onEnter()
{ 
	BaseLayer::onEnter();

	CButton *btn= (CButton *)m_ui->findWidgetById("close");
	btn->setOnClickListener(this,ccw_click_selector(CCommandLayer::onClose));

	m_cell = (CLayout*)(m_ui->findWidgetById("Cell"));
	m_cell->retain();
	m_ui->removeChild(m_cell);

	m_comLayer = (CLayout*)(m_ui->findWidgetById("pose"));
	m_garrsionLayer = (CLayout*)(m_ui->findWidgetById("garrsion"));

	m_tableView = (CTableView *)(m_ui->findWidgetById("scroll"));
	m_tableView->setDirection(eScrollViewDirectionVertical);
	m_tableView->setSizeOfCell(m_cell->getContentSize());
	m_tableView->setCountOfCell(0);
	m_tableView->setBounceable(false);
	m_tableView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CCommandLayer::tableviewDataSource));
	m_tableView->reloadData();

	m_selectCellImg = (CCSprite*)(m_ui->findWidgetById("selectImg"));
	m_selectCellImg->retain();

	CSceneManager::sharedSceneManager()->addMsgObserver("updateHero",this, GameMsghandler_selector(CCommandLayer::updateHero));

	CRadioBtnGroup *radioGroup = (CRadioBtnGroup *)m_ui->getChildByTag(10);
	for (int i = 0; i < 2; i++)
	{
		CRadioButton *radioBtn= (CRadioButton*)(radioGroup->getChildByTag(i+1));
		radioBtn->setOnCheckListener(this,ccw_check_selector(CCommandLayer::onSwitchBtn));
	}

	CButton *compose = (CButton *)(m_comLayer->findWidgetById("strengthen"));
	compose->setOnClickListener(this,ccw_click_selector(CCommandLayer::onComposeButton));
	compose->setDisabledImageColor();

	m_ui->setScale(0.0f);
	CCScaleTo *big = CCScaleTo::create(0.2f,1.0f);
	m_ui->runAction(big);

	GetTcpNet->registerMsgHandler(BuildInfo,this,CMsgHandler_selector(CCommandLayer::recBuildInfo));
	GetTcpNet->registerMsgHandler(CommanderMsg,this,CMsgHandler_selector(CCommandLayer::processNetMsg));
	//GetTcpNet->registerMsgHandler(ComposeItemMsg,this,CMsgHandler_selector(CCommandLayer::processNetMsg));
	GetTcpNet->registerMsgHandler(LevelUpMsg,this,CMsgHandler_selector(CCommandLayer::processNetMsg));

	for (int i=1; i<=3; ++i)
	{
		CButton *btn = dynamic_cast<CButton*>(m_garrsionLayer->getChildByTag(i));
		btn->setOnClickListener(this,ccw_click_selector(CCommandLayer::onGarrsion));
	}

	showSelectRadioImg(2);

}
Esempio n. 4
0
void CHandBookPanel::onEnter()
{
	BaseLayer::onEnter();

	//选项卡
	CRadioBtnGroup *radioGroup = (CRadioBtnGroup *)m_ui->findWidgetById("radio");
	for (unsigned int i=0; i<HandBookTabMax; i++)
	{
		CRadioButton *radioBtn= (CRadioButton*)(radioGroup->getChildByTag(i));
		radioBtn->setOnCheckListener(this,ccw_check_selector(CHandBookPanel::onSwitchBtn));
	}

	//退出
	CButton* pClose = CButton::create("common/back.png", "common/back.png");
	pClose->getSelectedImage()->setScale(1.1f);
	pClose->setPosition(VLEFT+50, VTOP-50);
	pClose->setOnClickListener(this,ccw_click_selector(CHandBookPanel::onClose));
	this->addChild(pClose, 999);

	//默认选择一个
	selectTabPanel(HandBookTabHero);
}