Esempio n. 1
0
void CChangeHeadImg::onChangHeadImg(CCObject* pSender)
{
	PlayEffectSound(SFX_Button);

	CImageView *head = (CImageView *)pSender;
	int *icon = (int*)head->getUserData();
	CPlayerControl::getInstance().sendChangeHeadImg(*icon);
	LayerManager::instance()->pop();
	LayerManager::instance()->pop();
}
Esempio n. 2
0
void CStrengthenItem::onTouchItem(CCObject* pSender)
{
	if(isVisible())
	{
		PlayEffectSound(SFX_Button);
	}

	CImageView * img = (CImageView*)pSender;
	m_item = (CItem*)img->getUserData();

	m_pItemTip->showItemProperty(m_item);

	CLayout *attribute = (CLayout*)(m_ui->findWidgetById("attr"));
	attribute->setVisible(true);

	m_selectCellImg->removeFromParent();
	img->addChild(m_selectCellImg);
	m_selectCellImg->setVisible(true);
	m_selectCellImg->setPosition(ccp(img->getContentSize().width/2,0/*img->getContentSize().height/2*/));

	CButton *select = (CButton*)(m_ui->findWidgetById("select")); //sel_font
	CLabel *selfont = (CLabel*)(m_ui->findWidgetById("sel_font"));
	if (m_toHero==m_item->armor.hero&&m_toHero>0)
	{
		select->setVisible(true);
		selfont->setVisible(false);
	}
	else if (m_toHero>0&&!m_item->canUse)
	{
		select->setVisible(false);
		selfont->setVisible(false);
	}
	else
	{
		select->setVisible(true);
		selfont->setVisible(true);
	}

	if (m_type==2)
	{
		if (m_toHero>0)
		{
			CImageView *uninstall = (CImageView*)(m_ui->findWidgetById("uninstall"));
			CImageView *change = (CImageView*)(m_ui->findWidgetById("change"));
			CImageView *selfont = (CImageView*)(m_ui->findWidgetById("sel_font"));
			uninstall->setVisible(m_toHero==m_item->armor.hero);
			change->setVisible(m_toHero!=m_item->armor.hero&&m_item->armor.hero>0&&m_item->canUse);
			selfont->setVisible(m_item->armor.hero==0&&m_item->canUse);
		}
	}
}
Esempio n. 3
0
void CSignLayer::onPress( CCObject* pSender, CTouchPressState iState )
{
	CImageView* pImage = (CImageView*)pSender;
	CSign* sign = (CSign*)pImage->getUserData();
	int iType = sign->prize.type;

	if(m_pMonsterInfo)
	{
		m_pMonsterInfo->hide();
	}
	if(m_pItemInfo)
	{
		m_pItemInfo->hide();
	}
	
	//1 道具,2 英雄,3 铜钱,4 元宝,5 粮食
	switch (iType)
	{
	case 3:
	case 4:
	case 5:
	case 1:
		{
			if(m_pItemInfo==nullptr)
			{
				m_pItemInfo = CItemInfo::create();
				this->addChild(m_pItemInfo);
			}

			switch (iState)
			{
			case CTouchPressOn:
				{
					PlayEffectSound(SFX_429);

					CSign* sign = (CSign*)pImage->getUserData();
					m_pItemInfo->setInfo(&sign->prize);
					m_pItemInfo->bindPos(pImage);
					m_pItemInfo->changeForSign(&sign->prize);
					m_pItemInfo->show();
					CCLOG("show");
				}
				break;
			case CTouchPressOff:
				{
					m_pItemInfo->hide();
					CCLOG("hide");
				}
				break;
			default:
				break;
			}

		}break;
	case 2:
		{
			if(m_pMonsterInfo==nullptr)
			{
				m_pMonsterInfo = CMonsterInfo::create();
				this->addChild(m_pMonsterInfo);
			}

			switch (iState)
			{
			case CTouchPressOn:
				{
					PlayEffectSound(SFX_429);

					CSign* sign = (CSign*)pImage->getUserData();
					CHero pHero;
					pHero.heroid = sign->prize.id;
					pHero.thumb = sign->prize.thumb;
					pHero.quality = sign->prize.quality;
					pHero.iColor = sign->prize.color;
					pHero.level = 1;
					m_pMonsterInfo->setHero(&pHero);
					m_pMonsterInfo->bindPos(pImage);
					m_pMonsterInfo->changeForSign(&pHero);
					m_pMonsterInfo->show();
					CCLOG("show");
				}
				break;
			case CTouchPressOff:
				{
					m_pMonsterInfo->hide();
					CCLOG("hide");
				}
				break;
			default:
				break;
			}

		}break;
	default:
		break;
	}

}