CCMenuItem* CPullMachMenu::itemForTouchPM(CCTouch * touch) { CCPoint touchLocation = touch->getLocation(); if (m_pChildren && m_pChildren->count() > 0) { CCObject* pObject = NULL; CCARRAY_FOREACH(m_pChildren, pObject) { CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject); if (pChild && pChild->isVisible() && pChild->isEnabled()) { CCPoint local = pChild->convertToNodeSpace(touchLocation); CCRect r; r.size = pChild->getContentSize(); r.origin.x = r.size.width * 0.2f; r.size.width *= 0.6f; r.origin.y = r.size.height * 0.2f; r.size.height *= 0.8f; if (r.containsPoint(local)) { return pChild; } } }
//设置按钮状态 void CStar97UILayer::setBtnEnable(enGameBtnTag eBtnTag, bool bEnabled) { CCMenuItem * pItem = dynamic_cast<CCMenuItem *>(m_pMenuLayer->getChildByTag(eBtnTag)); CCAssert(pItem != NULL, "this tag button don't have"); if (eBtnTag == GBTag_BetScore && bEnabled) { //判断是否为明星局 if (m_pGameLayer->isBetStarUseful()) pItem->setEnabled(bEnabled); else return; } else if (pItem->isEnabled() != bEnabled) pItem->setEnabled(bEnabled); }
///当点击CELL之后,判断是否点击到了某个菜单项,并置为选中状态 void CTableViewCell::selected(const CCPoint &touchPoint) { CCObject *pObject = NULL; CCARRAY_FOREACH_REVERSE(m_pArrItems, pObject) { CCMenuItem *pMenuItem = (CCMenuItem *) pObject; if(pMenuItem->isEnabled() && pMenuItem->isVisible()) { if(pMenuItem->boundingBox().containsPoint(touchPoint)) { pMenuItem->selected(); m_pTouchItem = pMenuItem; break; } } }