本文整理汇总了C++中CCLabelAtlas::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelAtlas::setVisible方法的具体用法?C++ CCLabelAtlas::setVisible怎么用?C++ CCLabelAtlas::setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelAtlas
的用法示例。
在下文中一共展示了CCLabelAtlas::setVisible方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: beAttacked
void RpgPlayer::beAttacked(int atkValue)
{
if (hp <= 0)
{
return;
}
int oldhp = hp;
if (hp >= atkValue)
{
hp -= atkValue;
}
else
{
hp = 0;
}
atkValue = oldhp-hp;
if (atkValue)
{
std::stringstream ss;
ss << atkValue;
//CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"fps_images.png", 12, 32, '.');
CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"numbers_1.png", 41.28, 81, '.');
labelAtlas->setVisible(true);
//labelAtlas->setPosition(ccp(125,125));
labelAtlas->setColor(ccc3(255,0,0));
CCAction *spawn = CCSpawn::create(CCMoveBy::create(0.5f,ccp(0,64)),CCFadeOut::create(0.5),NULL);
labelAtlas->runAction(spawn);
this->addChild(labelAtlas,2);
CCSprite::runAction(CCSequence::create(CCDelayTime::create(0.6),
CCCallFuncND::create(this, callfuncND_selector(RpgMonster::actionEnd_removeLabel), (void*)labelAtlas),NULL));
showHp();
tryConbineAction(RpgMonster::ACTION_BE_ATTACK);
}
if (ui)
{
ui->updateHp(this);
}
if (hp <=0)
{
doDeath(); // RpgMonster 将死亡
}
}
示例2: addGridCell
void CSignLayer::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
// CHero *hero = m_currHeroList->at(uIdx);
CSign &sign = m_signData.signList.at(uIdx);
CLayout *lay = UICloneMgr::cloneLayout(m_cell);
pCell->setScale(0.97f);
for (int i = 1; i <=4; i++)
{
CCNode *child = lay->getChildByTag(i);
lay->removeChild(child);
pCell->addChild(child);
}
CImageView *imagView = (CImageView*)pCell->getChildByTag(1);
imagView->setTouchEnabled(true);
imagView->setEnabled(true);
imagView->setUserData(&m_signData.signList.at(uIdx));
imagView->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
CCSprite *item = nullptr;
if (sign.prize.thumb>=0)
{
CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
SmartSetRectPrizeColor(pMask, &sign.prize);
item = CCSprite::create(GetImageName(sign.prize.type, sign.prize.color, sign.prize.thumb).c_str());
if(!item)
{
item = CCSprite::create("headImg/101.png");
CCLOG("CSignLayer::addGridCell error load image %d", sign.prize.thumb);
}
item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
pMask->addChild(item, -1, 2);
item->setScale(0.9f);
//加数字
CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
haveNum->setPosition(ccp(85, 5));
pMask->addChild(haveNum, 99, 99);
haveNum->setString(ToString(sign.prize.num));
if(sign.prize.num<=1)
{
haveNum->setVisible(false);
}
//添加星星
if(sign.prize.quality > 0)
{
CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
pMask->addChild(pStarLayout, 211, 211);
}
}
//vip icon
CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
if (sign.vip>0)
{
CCTexture2D *texture = CCTextureCache::sharedTextureCache()
->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
vip->setVisible(true);
vip->setTexture(texture);
}
else
{
vip->setVisible(false);
}
switch (sign.status)
{
//没签
case 2:
{
//对勾
pCell->getChildByTag(4)->setVisible(false);
//考虑是否加个框标示为可签
if(uIdx == m_signData.sign &&
(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
{
CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
CCSprite* pRect = CCSprite::create("common/box_light.png");
pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
pCell->addChild(pRect, 100);
pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
}
}
break;
//已签
case 1:
{
//对勾
pCell->getChildByTag(4)->setVisible(true);
//变黑
pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
//.........这里部分代码省略.........
示例3: showItemsNode
//.........这里部分代码省略.........
iTotalCount = this->getKaiBaoxiangRsqData().size();
if (iTotalCount >= 11)
{
xcount = 6;
}
if (iTotalCount == 2)
{
xcount = 2;
size = CCSizeMake(140*2, 190);
}
IOSStoreLayerScrollView* pView = IOSStoreLayerScrollView::createView(size, iTotalCount, xcount, ycount);
m_pGetItemNode->addChild(pView);
pView->ignoreAnchorPointForPosition(false);
pView->setAnchorPoint(ccp(0.5f, 0.5f));
pView->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2 - 60));
pView->setClickableCreater(pView);
pView->prepareToDisplay();
pView->setTouchEnabled(false);
pView->setTag(getitem_scrollview_tag);
//显示
CCSprite* pSmallbg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_anniu_zaikaishici_fujia.png").c_str());
m_pGetItemNode->addChild(pSmallbg, 1);
pSmallbg->setPosition(ccp(200, 100));
//添加菜单
CCMenu* pMenu = CCMenu::create();
pMenu->setPosition(CCPointZero);
m_pGetItemNode->addChild(pMenu, 2);
//再开按钮
CCMenuItemImage* pItem = NULL;
int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
if (m_bBaoxiangBuyTenTimes)
{
pItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pItem->setTag(buy_ten_again);
}
else
{
pItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pItem->setTag(buy_one_again);
}
pItem->setPosition(ccp(pSmallbg->getPositionX() + pSmallbg->getContentSize().width/2 + pItem->getContentSize().width/2 - 30,
pSmallbg->getPositionY()));
pMenu->addChild(pItem);
//星星数量
CCLabelAtlas* lable = CCLabelAtlas::create(
"0123456789",
ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
30, 47,//24
'0');
m_pGetItemNode->addChild(lable, 1, star_count_str_tag);
lable->setAnchorPoint(ccp(0, 0.5));
lable->setScale(0.6f);
int iCount = 10;
if (m_bBaoxiangBuyTenTimes)
{
iCount = 95;
}
char charStarCount[10] = {};
sprintf(charStarCount, "%d", iCount);
lable->setString(charStarCount);
lable->setPosition(ccp(pItem->getPositionX()-pItem->getContentSize().width/2-lable->getContentSize().width/2 - 40, pSmallbg->getPositionY() - 3));
//右边星星图标
CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
m_pGetItemNode->addChild(pXingxing, 1);
pXingxing->setPosition(ccp(lable->getPositionX() - 30, pSmallbg->getPositionY()));
//星星数不够时,只显示确定按钮
//确定按钮
CCMenuItemImage* pOKItem = CCMenuItemImage::create(
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi.png").c_str(),
ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi_select.png").c_str(),
this, menu_selector(IOSStoreLayer::menuBtnCallBack));
pOKItem->setTag(ok_btn_tag);
pOKItem->setPosition(ccp(this->getContentSize().width/2 + pOKItem->getContentSize().width, pSmallbg->getPositionY()));
pMenu->addChild(pOKItem);
if (iStarCount < iPrice)
{
lable->setVisible(false);
pXingxing->setVisible(false);
pSmallbg->setVisible(false);
pItem->setVisible(false);
pOKItem->setPosition(ccp(this->getContentSize().width/2, pSmallbg->getPositionY()));
}
pMenu->setTouchPriority(kCCMenuHandlerPriority-5);
}