本文整理汇总了C++中IconButton::creatDragReceiver方法的典型用法代码示例。如果您正苦于以下问题:C++ IconButton::creatDragReceiver方法的具体用法?C++ IconButton::creatDragReceiver怎么用?C++ IconButton::creatDragReceiver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IconButton
的用法示例。
在下文中一共展示了IconButton::creatDragReceiver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addOneEmptyPage
void UIScrollPage::addOneEmptyPage(int pageIndex)
{
CCLayer* layer = CCLayer::create();
layer->setAnchorPoint(ccp(0, 0));
{
int deltaX, deltaY;
if(m_cellBinFile == "")
{
m_cellBinFile = KUI_BIN;
}
ASprite *as = AspriteManager::getInstance()->getAsprite(m_cellBinFile);
int idx = getResourceIDByName(m_cellAsfile.c_str());
int selectedId = getResourceIDByName(m_cellSelectedAsfile.c_str());
CCSize buttonSize = as->getframeRect(idx).size;
// float contentScale = CCDirector::sharedDirector()->getContentScaleFactor();
// buttonSize = CCSizeMake(buttonSize.width * contentScale, buttonSize.height * contentScale);
if (m_icolumn <= 1)
deltaX = 0;
else
deltaX = (getContentSize().width - 2 * m_celloffsetX - buttonSize.width) / (m_icolumn - 1);
if (m_irow <= 1)
deltaY = 0;
else
deltaY = (getContentSize().height - 2 * m_celloffsetY - buttonSize.height) / (m_irow - 1);
/////////////////////////////////////////////////////////////////////////////
// row
// row
for(int r = 0; r < (int)m_irow; r++)
{
for(int l = 0; l < (int) m_icolumn; l++)
{
// clone one ccsprite
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(UIScrollPage::OnItemClicked));
pIcon->autorelease();
int index = pageIndex * m_icolumn * m_irow;
index += r * m_icolumn + l;
pIcon->SetButtonIndex(index+1);
pIcon->setContentSize(pEmptyItem->getContentSize());
if(m_itemType != 0)
{
pIcon->creatDragReceiver((DragHandlerType)m_itemType);
}
pIcon->SetDoubleClickHandler(this,menu_selector(UIScrollPage::OnItemDoubleClicked));
pIcon->SetTappedHandler(this,menu_selector(UIScrollPage::OnTapped),menu_selector(UIScrollPage::OnTapCancel));
pIcon->SetDragFlagTime(150);
m_lstButton.push_back(pIcon);
int x = l * deltaX + m_celloffsetX + buttonSize.width / 2 - getContentSize().width / 2 ;
int y = getContentSize().height / 2 - (r * deltaY + m_celloffsetY + buttonSize.height / 2);
// x /= contentScale;
// y /= contentScale;
pIcon->setPosition(ccp(x, y));
char name[50];
sprintf(name,"%s_%d",this->m_strName.c_str(),index+1);
pIcon->SetButtonName(name);
layer->addChild(pIcon);
}
}
}
addPage(layer);
}