本文整理汇总了C++中IconButton::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ IconButton::addChild方法的具体用法?C++ IconButton::addChild怎么用?C++ IconButton::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IconButton
的用法示例。
在下文中一共展示了IconButton::addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addNewSever
void FrontCoverLayer::addNewSever()
{
UILayout* m_layout = UIManager::sharedManager()->getUILayout("SplashLayout");
if(m_severScrollPage)
{
CCLayer* layer = CCLayer::create();
m_severScrollPage->addPage(layer);
int count = m_severList.size();
int currentPage = 0;
int column = 3;
int row = 2;
ASprite *as = AspriteManager::getInstance()->getAsprite(KUI_BIN);
int idx = map_ui_FRAME_SELECTSERVE_BUTTON;
int selectedId = map_ui_FRAME_SELECTSERVE_BUTTON_CLICKED;
float scale = UIManager::sharedManager()->getScaleFactor();
float width = m_severScrollPage->getContentSize().width / scale;
float height = m_severScrollPage->getContentSize().height / scale;
CCRect rect = as->getframeRect(idx);
float deltaWidth = (width - column * rect.size.width )/(column + 1);
float deltaHeigth = (height - row * rect.size.height )/(row + 1);
for(int i =0; i< count; i++)
{
int index = i;
int page = index / (column * row);
int rowIndex = (index - page * column * row) / column;
int columnIndex = (index - page * column * row) % column;
if(page != currentPage)
{
currentPage = page;
CCLayer* newlayer = CCLayer::create();
m_severScrollPage->addPage(newlayer);
}
CCPoint pt;
CCSprite *pEmptyItem = as->getSpriteFromFrame_Middle( idx, 0, pt);
CCSprite *pSelectedItem = as->getSpriteFromFrame_Middle(selectedId ,0,pt);
IconButton * pIcon = new IconButton(pEmptyItem, NULL, pSelectedItem, this,
menu_selector(FrontCoverLayer::onClickedOneSever));
pIcon->autorelease();
pIcon->SetButtonIndex(index);
pIcon->setContentSize(pEmptyItem->getContentSize());
float x = -width * 0.5f + deltaWidth * (columnIndex + 1) + (columnIndex + 0.5f) * rect.size.width ;
float y = height * 0.5f - (rowIndex + 0.5f) * (deltaHeigth + rect.size.height );
pIcon->setPosition(ccp(x, y));
UILabelTTF* label = UILabelTTF::create(m_severList[i]->name,KJLinXin,40,pEmptyItem->getContentSize(),kCCTextAlignmentCenter,kCCVerticalTextAlignmentCenter);
pIcon->addChild(label);
m_lstButton.push_back(pIcon);
CCLayer* currentLayer = m_severScrollPage->getPageLayer(currentPage);
currentLayer->addChild(pIcon,index);
}
}
}