コード例 #1
0
ファイル: TopLayer.cpp プロジェクト: 54993306/Classes
void CTopLayer::onEnter()
{
	BaseLayer::onEnter();
	this->setTouchPriority(-100);
	UserData *user = DataCenter::sharedData()->getUser()->getUserData();

	m_coinLabel = (CLabel*)m_ui->getChildByTag(13);
	m_coinLabel->setString(ToString(user->getCoin()));

	m_moneyLabel = (CLabel*)m_ui->getChildByTag(14);
	m_moneyLabel->setString(ToString(user->getRoleGold()));
	// 
	m_foodLabel = (CLabel*)m_ui->getChildByTag(17);
	//m_foodLabel->setString(ToString(user->getRoleFood()));
	m_foodLabel->setString(ToString(user->getFriends()));

	CLabel *action = (CLabel*)(m_ui->findWidgetById("action"));
	action->setString(CCString::createWithFormat("%d/%d",user->getRoleAction(),user->getActionLimit())->getCString());

	CButton* add_food = (CButton*)m_ui->findWidgetById("btn_add_food");
	CButton* add_copper = (CButton*)m_ui->findWidgetById("btn_add_copper");
	CButton* add_soul = (CButton*)m_ui->findWidgetById("btn_add_soul");
	CButton* add_gold = (CButton*)m_ui->findWidgetById("btn_add_gold");
	CButton* add_friendship = (CButton*)m_ui->findWidgetById("btn_add_friendship");
	add_food->getSelectedImage()->setScale(1.1f);
	add_copper->getSelectedImage()->setScale(1.1f);
	add_soul->getSelectedImage()->setScale(1.1f);
	add_gold->getSelectedImage()->setScale(1.1f);
	add_friendship->getSelectedImage()->setScale(1.1f);
	add_food->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
	add_copper->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
	add_soul->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
	add_gold->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
	add_friendship->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
	CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_HERO,this,GameMsghandler_selector(CTopLayer::updateRoleProperty));

	//绑定场景隐藏和显示的消息
	NOTIFICATION->addObserver(this, callfuncO_selector(CTopLayer::show), SHOW_TOP_LAYER, nullptr);
	NOTIFICATION->addObserver(this, callfuncO_selector(CTopLayer::hide), HIDE_TOP_LAYER, nullptr);

	CImageView *coin = (CImageView*)(m_ui->findWidgetById("coin"));
	CCAnimation *coinAnim = AnimationManager::sharedAction()->getAnimation("7033");
	coinAnim->setDelayPerUnit(0.3f);
	coin->runAction(CCRepeatForever::create(CCAnimate::create(coinAnim)));

	CImageView *gold = (CImageView*)(m_ui->findWidgetById("gold"));
	CCAnimation *goldAnim = AnimationManager::sharedAction()->getAnimation("7034");
	goldAnim->setDelayPerUnit(0.3f);
	gold->runAction(CCRepeatForever::create(CCAnimate::create(goldAnim)));
}
コード例 #2
0
ファイル: SmeltArmor.cpp プロジェクト: 54993306/Classes
void CSmeltArmor::onEnter()
{
	BaseLayer::onEnter();

	//四个选择框
	for (unsigned int i=0; i<4; ++i)
	{
		CCheckBox *checkBtn = (CCheckBox*)(m_pBaseInfo[i]->findWidgetById("check"));
		checkBtn->setOnCheckListener(this,ccw_check_selector(CSmeltArmor::onCheckAttr));
	}

	//选择武器
	CButton *select = (CButton*)(m_ui->findWidgetById("select"));
	select->setOnClickListener(this, ccw_click_selector(CSmeltArmor::onSelectItem));

	//洗练
	CButton *refine = (CButton*)(m_ui->findWidgetById("refine"));
	refine->setOnClickListener(this, ccw_click_selector(CSmeltArmor::onRefineItem));
	
	//初始化火
	initFire();

	//旋转圈
	CImageView *circleFire = (CImageView*)(m_ui->findWidgetById("fire_circle"));
	circleFire->setScale(1.95f);
	circleFire->runAction(CCRepeatForever::create(CCRotateBy::create(1.0f, 60)));
	circleFire->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(1.2f, 2.1f), CCScaleTo::create(1.2f, 1.95f))));


	GetTcpNet->registerMsgHandler(SmeltArmorMsg,this,CMsgHandler_selector(CSmeltArmor::proceesMessage));
	GetTcpNet->registerMsgHandler(SmeltDataRequestMsg,this,CMsgHandler_selector(CSmeltArmor::proceesMessage));

	CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_HERO, this, GameMsghandler_selector(CSmeltArmor::roleUpdate));
	
	CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_ITEM_DATA, this, GameMsghandler_selector(CSmeltArmor::updateStar));
}
コード例 #3
0
ファイル: SignLayer.cpp プロジェクト: 54993306/Classes
void CSignLayer::callBackForTotalSignEffectOneFrameLater()
{
	//隐藏黄标
	m_pYellowTip->setVisible(false);

	//触摸屏蔽
	MaskLayer* pLayer1 = MaskLayer::create("CSignLayer::callBackForTotalSignEffect1");
	pLayer1->setOpacity(0);
	LayerManager::instance()->push(pLayer1);
	MaskLayer* lay = MaskLayer::create("CSignLayer::callBackForTotalSignEffect2");
	lay->setContentSize(CCSizeMake(1138,640));
	lay->setAnchorPoint(ccp(0.5f, 0.5f));
	lay->setPosition(VCENTER);
	lay->setOpacity(0);
	LayerManager::instance()->push(lay);

	//开宝箱
	int iIndexTotal = checkTotalBox();
	if(iIndexTotal==-1)
	{
		//触摸释放
		LayerManager::instance()->pop();
		LayerManager::instance()->pop();
		return;
	}

	int iTag = 9065+iIndexTotal;
	CCString* pStr = CCString::createWithFormat("%d", iTag);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(CCString::createWithFormat("skill/%s.plist", pStr->getCString())->getCString());
	AnimationManager::sharedAction()->ParseAnimation(pStr->getCString());
	CCAnimation *culAnim = AnimationManager::sharedAction()->getAnimation(pStr->getCString());
	culAnim->setDelayPerUnit(0.15f);
	CCAnimate* pAnimate = CCAnimate::create(culAnim);
	CImageView *mask = (CImageView*)m_ui->findWidgetById(CCString::createWithFormat("mask%d",iIndexTotal+1)->getCString());	
	mask->setVisible(false);
	CImageView* pSprite = UICloneMgr::cloneImageView(mask);
	pSprite->setVisible(true);
	pSprite->setId("mask_copy");
	pSprite->runAction(CCSequence::create(
		pAnimate, 
		CCCallFunc::create(this, callfunc_selector(CSignLayer::callBackForTotalSignEffectEnd)),
		nullptr
		));
	mask->getParent()->addChild(pSprite);
}
コード例 #4
0
ファイル: HandBookHero.cpp プロジェクト: 54993306/Classes
void CHandBookHeroLayer::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
	//先克隆外框条
	CLayout *pLay = UICloneMgr::cloneLayout(m_pCellBlank);

	//对应数据
	AtlasIns *pAtlasIns = m_AtlasResponse.mutable_atlas_list()->Mutable(uIdx);

	//赋值
	for (unsigned int i=1; i<=10; i++)
	{
		CCNode *child = pLay->getChildByTag(i);
		pLay->removeChild(child);
		child->setTag(i);
		pCell->addChild(child);
		pCell->setTag(uIdx);
	}

	//1-活动底板
	{
		CImageView* pBoard = dynamic_cast<CImageView*>(pCell->getChildByTag(1));
		pBoard->setTouchEnabled(true);
		pBoard->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickBlank));

		if ( uIdx==m_iSelectIndex )
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_2.png"));
		}
		else
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_1.png"));
		}
	}

	//2-组合名字
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(2));
	}

	//3-//组合描述
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(3));
	}

	//4-礼品背景
	//5-礼品
	//10-文字
	{
		CImageView* pGiftBg = dynamic_cast<CImageView*>(pCell->getChildByTag(4));
		CImageView* pGift = dynamic_cast<CImageView*>(pCell->getChildByTag(5));
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(10));

		pLabel->setVisible(false);
		pGift->stopAllActions();

		//奖励领取标志 0未领取(不可领取),1未领取(可领取状态),2 已领取
		switch (pAtlasIns->get_prize())
		{
		case 0:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));

			}break;
		case 1:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				ResetAnchorPointAndKeepSamePos(pGift, CCPointCenter);
				pGift->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 0.75f), CCScaleTo::create(0.3f, 0.7f))));

			}break;
		case 2:
			{
				pGiftBg->setVisible(false);
				pGift->setVisible(false);
				pLabel->setVisible(true);
			}break;
		default:
			break;
		}
	}


	//7-进度条
	//8-进度数字
	//9-进度图标
	{
		CProgressBar* pProgress = dynamic_cast<CProgressBar*>(pCell->getChildByTag(7));

		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(8));
		pLabel->setTouchEnabled(true);
		pLabel->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));

		CImageView* pIcon = dynamic_cast<CImageView*>(pCell->getChildByTag(9));
		pIcon->setTouchEnabled(true);
		pIcon->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));
	}


	//收集列表
	CCPoint pPos(80, 54);
	int iGapX = 94;
	initListCellIcon( pAtlasIns, pPos, iGapX, pCell );

}