bool CSignLayer::init() { if (BaseLayer::init()) { MaskLayer* lay = MaskLayer::create("CSignLayermask"); lay->setContentSize(CCSizeMake(2824,640)); LayerManager::instance()->push(lay); m_ui = LoadComponent("Sign.xaml"); // SelectSkill m_ui->setPosition(VCENTER); this->addChild(m_ui); this->setOpacity(180); //背景框 CImageView* pImageRect = (CImageView*)m_ui->findWidgetById("board_sign"); //添加一个裁切层 CCClippingNode* pClip = CCClippingNode::create(); CImageView* pImage = UICloneMgr::cloneImageView(pImageRect); pImage->setAnchorPoint(ccp(0.5f, 0.5f)); pImage->setPosition(ccp(pImage->getContentSize().width/2, pImage->getContentSize().height/2)); pClip->setStencil(pImage); pClip->setContentSize(pImageRect->getContentSize()); pClip->setAnchorPoint(pImageRect->getAnchorPoint()); pClip->setPosition(pImageRect->getPosition()); pImageRect->getParent()->addChild(pClip, pImageRect->getZOrder()+1); m_pClip = pClip; //展示区图片 m_show_info_scroll = (CScrollView*)m_ui->findWidgetById("scroll_info"); m_show_info_scroll->setDirection(eScrollViewDirectionVertical); m_show_info_scroll->setBounceable(true); m_pInfo1 = (CLabel*)m_ui->findWidgetById("info_1"); CC_SAFE_RETAIN(m_pInfo1); m_pInfo1->removeFromParentAndCleanup(false); m_show_info_scroll->getContainer()->addChild(m_pInfo1); m_pInfo1->setAnchorPoint(ccp(0, 1)); CC_SAFE_RELEASE(m_pInfo1); m_pInfo2 = (CLabel*)m_ui->findWidgetById("info_2"); CC_SAFE_RETAIN(m_pInfo2); m_pInfo2->removeFromParentAndCleanup(false); m_show_info_scroll->getContainer()->addChild(m_pInfo2); m_pInfo2->setAnchorPoint(ccp(0, 1)); CC_SAFE_RELEASE(m_pInfo2); updateShowInfoScroll(); m_show_info_scroll->setVisible(false); CCNode* pMaskInfo = (CCNode*)m_ui->findWidgetById("mask_info"); pMaskInfo->setVisible(false); m_pLineEffect = new CLineLightEffect; m_pLineEffect->bindUI(m_ui); m_pLineEffect->bindRectEffect(pImageRect); this->addChild(m_pLineEffect, 999); m_pYellowTip = CCSprite::create("sign/lightbox5.png"); m_pYellowTip->setAnchorPoint(ccp(0.5f, 0.0f)); m_pYellowTip->setScale(0.8f); m_pYellowTip->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCMoveBy::create(0.3f, ccp(0, -10)), CCMoveBy::create(0.3f, ccp(0, 10))))); m_ui->addChild(m_pYellowTip, 50); m_pYellowTipText = UICloneMgr::cloneLable((CLabel*)m_ui->findWidgetById("day1")); m_pYellowTipText->setAnchorPoint(ccp(0.5f, 0.5f)); m_pYellowTipText->setPosition(ccp(m_pYellowTip->getContentSize().width/2, m_pYellowTip->getContentSize().height/2+12)); m_pYellowTipText->setScale(1.2f); m_pYellowTip->addChild(m_pYellowTipText); m_pYellowTip->setVisible(false); return true; } return false; }
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()); //} label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString()); } } else if (i==6) { CCSprite *head = (CCSprite*)child; if (item.armor.hero>0) { CCSprite *img = CCSprite::create(getImageName(&item.armor).c_str()); if(!img) { img = CCSprite::create("headIcon/101.png"); CCLOG("ERROR CStrengthenItem::addTableCell"); } CCSprite *mask = (CCSprite*) lay->getChildByTag(7); lay->removeChild(mask); pCell->addChild(mask); img->setScale(0.53f); img->setPosition(ccp(head->getContentSize().width/2,head->getContentSize().height/2+14)); head->addChild(img); } else { pCell->removeChild(child); } } else if (i==7) { pCell->removeChild(child); } else if (i==8) { child->setVisible(item.stren); } else if(i==9) { if (item.itemLevel==0) { child->setVisible(false); } else { child->setVisible(true); } } else if( i ==10) { CCNode* pCombatTip = (CCNode*)child; pCombatTip->setVisible(item.armor.armorType != 5); } else if (i==11) { CLabelAtlas* pLabel = (CLabelAtlas*)child; pLabel->setAnchorPoint(ccp(0, 0.5f)); pLabel->setString(ToString(item.armor.combat)); pLabel->setVisible(item.armor.armorType != 5); } } }