Esempio n. 1
0
void CVipCard::onEnter()
{
	BaseLayer::onEnter();
	//确定
	CButton* pConfirm = (CButton*)m_ui->findWidgetById("confirm");
	pConfirm->setOnClickListener(this, ccw_click_selector(CVipCard::onConfirm));

	CButton* cancel = (CButton*)m_ui->findWidgetById("cancel");
	cancel->setOnClickListener(this, ccw_click_selector(CVipCard::onCancel));

	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(CVipCard::onClose));
	this->addChild(pClose, 999);
	
	CImageViewScale9* pRect1 = (CImageViewScale9*)m_ui->findWidgetById("rect1");
	m_cardText = CursorTextField::textFieldWithPlaceHolder("", FONT_NAME, 29, CCSize(690, 110), ccBLACK);
	m_cardText->setPriority(this->getTouchPriority());
	m_cardText->setLimitNum(17);
	m_cardText->setAnchorPoint(ccp(0, 0.5f));
	m_cardText->setPosition( ccp(pRect1->getPositionX()-440, pRect1->getPositionY()));
	m_ui->addChild(m_cardText, 999);

	//展示区图片
	CLayout *pShowInfo = CLayout::create();

	CScrollView *pScroll = (CScrollView*)m_ui->findWidgetById("scroll_info");
	pScroll->setDirection(eScrollViewDirectionVertical);
	pScroll->setBounceable(false);
	pScroll->getContainer()->addChild(pShowInfo);

	CCSize size = CCSize(957, 471);
	pShowInfo->setContentSize(size);
	pScroll->setContainerSize(size);
	pShowInfo->setPosition(ccp(pScroll->getContainerSize().width*0.5f, pScroll->getContainerSize().height*0.5f));
	pScroll->setContentOffsetToTop();

	//嫁接内容
	CLayout* pLayout = (CLayout*)findWidgetById("layer_info");
	pLayout->retain();
	pLayout->removeFromParent();
	pShowInfo->addChild(pLayout);
	pLayout->release();
	pLayout->setPosition(ccp(size.width/2, size.height/2+10));

}
Esempio n. 2
0
void LoginLayerUC::initLogin()
{
	CCLOG("LoginLayerUC::initLogin");

	if(m_ui!=nullptr)
	{
		return;
	}

	//播放背景音乐
	PlayBackgroundMusic(BGM_Login,true);

	m_ui = LoadComponent("EnterGameUC.xaml");
	m_ui->setTag(1);
	m_ui->setPosition(VCENTER);
	m_LayoutRoot->addChild(m_ui, 2);

	//自己的登陆框隐藏
	m_pLoginLay = (CLayout *)m_ui->getChildByTag(10);
	m_pLoginLay->setVisible(false);

	//选择好的服务器列表
	m_pCurrentServerUI = (CLayout *)m_ui->findWidgetById("current_server");
	m_pCurrentServerUI->setVisible(true);


	//默认服务器
	updateSelectServer();

	//服务器选区
	CLayout* pLayout = (CLayout*)m_ui->findWidgetById("serverCell");
	pLayout->retain();
	m_ui->removeChild(pLayout);
	m_pCell = pLayout;

	//获取空的滑动列表Scroll
	m_pTableView = (CTableView*)m_ui->findWidgetById("serverScroll");
	m_pTableView->setDirection(eScrollViewDirectionVertical);
	m_pTableView->setSizeOfCell(m_pCell->getContentSize());
	m_pTableView->setCountOfCell(m_serverInfo.server_list().size());
	m_pTableView->setBounceable(true);
	m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(LoginLayerUC::tableviewDataSource));
	m_pTableView->reloadData();


	//按钮打开服务器列表
	CImageView* pBtnServer = (CImageView*)m_ui->findWidgetById("serverBtn");


	//快速登录按钮
	CButton * pQuickLogin = (CButton *)m_ui->getChildByTag(1);
	pQuickLogin->setOnClickListener(this,ccw_click_selector(LoginLayerUC::onQuickLogin));
	CCActionInterval *scaleSmall = CCScaleTo::create(0.9f,0.98f);
	CCFadeTo *out = CCFadeTo::create(0.9f,60);
	CCSpawn *spawn = CCSpawn::createWithTwoActions(scaleSmall,out);
	CCActionInterval *scaleBig = CCScaleTo::create(1.2f,1.0f);
	CCFadeTo *in = CCFadeTo::create(1.2f,255);
	CCSpawn *spawn1 = CCSpawn::createWithTwoActions(scaleBig,in);
	CCSequence *seque = CCSequence::createWithTwoActions(spawn,spawn1);
	CCRepeatForever *action = CCRepeatForever::create(seque);
	pQuickLogin->runAction(action);
	pQuickLogin->setVisible(true);

	//清除用户信息
	DataCenter::sharedData()->getUser()->clear();

	//版本做相对位置处理
	CLabel* pLabel = (CLabel *)m_ui->findWidgetById("version");
	pLabel->setAnchorPoint(ccp(1.0f, 0.0f));
	pLabel->setPosition(ccp(VRIGHT-20, VBOTTOM+20));
	CC_SAFE_RETAIN(pLabel);
	pLabel->removeFromParentAndCleanup(true);
	this->addChild(pLabel);
	CC_SAFE_RELEASE(pLabel);
	pLabel->setString(CCString::createWithFormat("Version:%s", m_serverInfo.game_version().c_str())->getCString());


	//隐藏服务器列表
	showServerList();
	hideServerList();


	//TODO
	//初始化UC_SDK?-放在最前面
	//还是点击登录再初始化?
	//点击登录再初始化吧
	//初始化完直接请求登录


	//先连接连接服务器
	const Server& gameServer = m_serverInfo.server_list().Get(m_iSelectServerIndex);

	//检查服务器是否可用
	if(!checkServerStatus(gameServer))	
	{
		return;
	}

	LinkedGameServer(gameServer);
}