本文整理汇总了C++中CImageView::setOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:C++ CImageView::setOnClickListener方法的具体用法?C++ CImageView::setOnClickListener怎么用?C++ CImageView::setOnClickListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImageView
的用法示例。
在下文中一共展示了CImageView::setOnClickListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addGridCell
void CChangeHeadImg::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
CLayout *lay = UICloneMgr::cloneLayout(m_cell);
for (int i=1; i<=2; i++)
{
CCNode *child = lay->getChildByTag(i);
lay->removeChild(child);
pCell->addChild(child);
if (i==1)
{
if (m_headIconList.at(uIdx)>0)
{
CImageView* pHead = CImageView::create(CCString::createWithFormat("headImg/%d.png", m_headIconList.at(uIdx))->getCString());
if(!pHead)
{
pHead = CImageView::create("headImg/null.png");
CCLOG("ERROR_____CChangeHeadImg::addGridCell");
}
child->addChild(pHead);
NodeFillParent(pHead);
}
else
{
UserData *data = DataCenter::sharedData()->getUser()->getUserData();
string fbName = data->getFbId() +".jpg";
string fullName = CCFileUtils::sharedFileUtils()->fullPathForFilename(fbName.c_str());
bool isFileExist = CCFileUtils::sharedFileUtils()->isFileExist(fullName);
if(isFileExist)
{
CCSprite* spr =CCSprite::create(fullName.c_str());
child->addChild(spr);
NodeFillParent(spr);
}
}
}
else if(i==2)
{
CImageView* pBtn = (CImageView*)child;
pBtn->setTouchEnabled(true);
pBtn->setUserData(&m_headIconList.at(uIdx));
pBtn->setOnClickListener(this,ccw_click_selector(CChangeHeadImg::onChangHeadImg));
}
}
}
示例2: addTableCell
void LoginLayerUC::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
CLayout *lay = UICloneMgr::cloneLayout(m_pCell);
const Server& server = m_serverInfo.server_list().Get(uIdx);
for (unsigned int i=1; i<=4; i++)
{
CCNode *child = lay->getChildByTag(i);
lay->removeChild(child);
child->setTag(i);
pCell->addChild(child);
pCell->setTag(uIdx);
switch (i)
{
case 1:
{
CImageView* pBoard = (CImageView*)child;
pBoard->setTouchEnabled(true);
pBoard->setOnClickListener(this, ccw_click_selector(LoginLayerUC::selectServer));
}
break;
case 3:
{
CLabel* pLabel = (CLabel*)child;
pLabel->setString(server.server_name().c_str());
}
break;
case 4:
{
CLabel* pLabel = (CLabel*)child;
int iShowText[5] = {2002, 1184, 1185, 1186, 1187};
pLabel->setString(GETLANGSTR(iShowText[server.server_status()]));
}
break;
default:
break;
}
}
}
示例3: addTableCell
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));
}
//.........这里部分代码省略.........
示例4: addTableCell
void CStrengthenItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
CLayout *lay = UICloneMgr::cloneLayout(m_cell);
CItem &item = *(m_itemList.at(uIdx));// m_itemData.itemList.at(uIdx);
pCell->setTag(uIdx);
const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(item.itemId);
for (int i = 1; i <=11; i++)
{
CCNode *child = lay->getChildByTag(i);
if (!child) continue;
lay->removeChild(child);
pCell->addChild(child);
if (i==1)
{
CImageView *bgImg = (CImageView*)child;
if (m_toHero>0)
{
if (!item.canUse&&item.armor.hero!=m_toHero)
{
CColorView *colorView = CColorView::create(ccc4(0,0,0,100));
colorView->setContentSize(bgImg->getContentSize());
colorView->setPosition(bgImg->getPosition());
pCell->addChild(colorView,1);
}
if(item.armor.hero<=0)
{
//记录库存
m_iCountEquipStock++;
}
}
bgImg->setTouchEnabled(true);
bgImg->setUserData(m_itemList.at(uIdx));
bgImg->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onTouchItem));
}
else if (i==2)
{
((CButton*)child)->setEnabled(false);
CCSprite *mask = CCSprite::createWithTexture(setItemQualityTexture(item.quality));
mask->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
child->addChild(mask, 10);
CCSprite *prop = CCSprite::create(GetImageName(1, item.quality, item.iconId).c_str());
if (!prop)
{
prop = CImageView::create("prop/32003.png");
}
prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
child->addChild(prop);
//添加星星
CLayout* pStarLayout = getStarLayout(item.iStar);
child->addChild(pStarLayout, 10);
}
else if (i==3)
{
CLabel *label = (CLabel*)child;
if(itemData)
{
label->setString(itemData->itemName.c_str());
}
}
else if (i==4)
{
CLabel *label = (CLabel*)child;
if (item.itemLevel==0)
{
label->removeFromParent();
}
else
{
label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString());
label->setPositionX(pCell->getChildByTag(3)->getPositionX()+pCell->getChildByTag(3)->getContentSize().width+10);
}
}
else if (i==5)
{
CLabel *label = (CLabel*)child;
if (item.itemLevel==0)
{
label->setVisible(false);
}
else
{
label->setVisible(true);
//if (item.itemLevel==item.armor.strenLv)
//{
// label->setString(CCString::createWithFormat("Lv.%s",GETLANGSTR(229))->getCString());
//}
//else
//{
// label->setString(CCString::createWithFormat("Lv.%d",item.itemLevel)->getCString());
//}
//.........这里部分代码省略.........
示例5: onEnter
void CMainCityUI::onEnter()
{
BaseLayer::onEnter();
UserData *user = DataCenter::sharedData()->getUser()->getUserData();
//角色信息相对位置处理
CLayout* headPart = (CLayout*)m_ui->findWidgetById("head_part");
headPart->setPosition(m_ui->convertToNodeSpace(ccp(VLEFT+headPart->getContentSize().width/2, VTOP-headPart->getContentSize().height/2)));
//显示角色名,等级,体力,金币
CLabel *nameLabel = (CLabel*)headPart->getChildByTag(10);
nameLabel->setString(user->getRoleName().c_str());
nameLabel->setColor(RGB_ROLE_COLOR);
CLabel *level = (CLabel*)(headPart->findWidgetById("level"));
level->setString(CCString::createWithFormat("Lv%d",user->getLevel())->getCString());
CProgressBar *progressBar = (CProgressBar*)(headPart->getChildByTag(11));
progressBar->setMaxValue(user->getNextExp());
progressBar->startProgress(user->getExp(),0.3f);
CLabelAtlas *vip_level = (CLabelAtlas*)(headPart->findWidgetById("level_vip"));
vip_level->setString(ToString(user->getVip()));
if (user->getVip()==0)
{
vip_level->setVisible(false);
CLabelAtlas *vip_font = (CLabelAtlas*)(headPart->findWidgetById("vip_font"));
vip_font->setVisible(false);
}
CImageView *headbg = (CImageView *)(headPart->findWidgetById("headbg"));
headbg->setTouchEnabled(true);
headbg->setOnClickListener(this, ccw_click_selector(CMainCityUI::onHeadImgBtn));
CButton *button = nullptr;
int i = 1;
for (; i<=9; ++i)
{
CCNode *lay = dynamic_cast<CCNode*>( m_ui->getChildByTag(i));
button = dynamic_cast<CButton*>(lay->getChildByTag(i));
// button->setEnabled(false);
button->setOnClickListener(this, ccw_click_selector(CMainCityUI::onClickBtn));
button->setSelectedTexture(((CCSprite*)(button->getNormalImage()))->getTexture());
button->getSelectedImage()->setScale(1.1f);
m_btnPos[i] = button->getPosition();
}
CCSprite* head = (CCSprite*)headPart->getChildByTag(15);
if (user->getThumb()>0)
{
CCTexture2D *texture = CCTextureCache::sharedTextureCache()
->addImage(CCString::createWithFormat("headIcon/%d.png", user->getThumb())->getCString());
if (texture)
{
head->setTexture(texture);
}
}
else
{
string fbName = user->getFbId()+".jpg";
string fullName = CCFileUtils::sharedFileUtils()->fullPathForFilename(fbName.c_str());
bool isFileExist = CCFileUtils::sharedFileUtils()->isFileExist(fullName);
if(isFileExist)
{
CCSprite *headBg = (CCSprite *)(headPart->findWidgetById("headbg"));
CCSprite *sp = CCSprite::create(fbName.c_str());
CCSprite* spr = MakeFaceBookHeadToCircle(sp);
spr->setPosition(headBg->getPosition());
headPart->removeChild(head);
spr->setTag(15);
headPart->addChild(spr);
}
else
{
HttpLoadImage::getInstance()->bindUiTarget(this);
CCString *imgUrl = CCString::createWithFormat(FACEBOOKIMG_106,user->getFbId().c_str());
HttpLoadImage::getInstance()->requestUrlImage(imgUrl->getCString(),user->getFbId().c_str());
}
}
CImageView* vip = (CImageView*)headPart->findWidgetById("vip");
vip->setTouchEnabled(true);
vip->setOnClickListener(this,ccw_click_selector(CMainCityUI::onVip));
//添加签到,充值等其他入口
CAccessLayer* pAccess = CAccessLayer::create();
this->addChild(pAccess, 99);
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_HERO,this,GameMsghandler_selector(CMainCityUI::updateRoleProperty));
CSceneManager::sharedSceneManager()->addMsgObserver(TASK_NOTICE,this,GameMsghandler_selector(CMainCityUI::updateTaskNotice));
CSceneManager::sharedSceneManager()->addMsgObserver(MAIL_NOTICE,this,GameMsghandler_selector(CMainCityUI::updateMailNotice));
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_FUNCTIONOPEN,this,GameMsghandler_selector(CMainCityUI::updateFuctionOpen));
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_GAMETIP,this,GameMsghandler_selector(CMainCityUI::updateGameTip));
CSceneManager::sharedSceneManager()->addMsgObserver(SHOW_HEAD,this,GameMsghandler_selector(CMainCityUI::showHead));
CCSprite *red = (CCSprite*)(m_ui->findWidgetById("redPoint"));
CCSprite *mailPoint = (CCSprite*)(m_ui->findWidgetById("mailPoint"));
//.........这里部分代码省略.........