cocos2dx 某缩放的页面 CCTableView最后一个标签无法点中

有一个二级界面,在ipad4下面放大到1.6倍,直接对最外层的CCLayer缩放的,里面包含有CCTableView。结果运行的时候无法选中到最后一个标签,无论总的标签是2个还是更多,单步调试,发现到ccTouchEnded的时候判断的点击范围有问题,修改成下面的就好了。具体原因没有时间解释了,大家看看估计也明白了。

原:

void CCTableView::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
    if (!this->isVisible()) {
        return;
    }

    if (m_pTouchedCell){
        CCRect bb = this->boundingBox();
        bb.origin = m_pParent->convertToWorldSpace(bb.origin);

        if (bb.containsPoint(pTouch->getLocation()) && m_pTableViewDelegate != NULL)
        {
            m_pTableViewDelegate->tableCellUnhighlight(this, m_pTouchedCell);
            m_pTableViewDelegate->tableCellTouched(this, m_pTouchedCell);
        }

        m_pTouchedCell = NULL;
    }

    CCScrollView::ccTouchEnded(pTouch, pEvent);
}

新:

void CCTableView::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
    if (!this->isVisible()) {
        return;
    }

    if (m_pTouchedCell){

        CCPoint touchLocation = pTouch->getLocation(); // Get the touch position
        touchLocation = m_pParent->convertToNodeSpace(touchLocation);

        CCRect bb = this->boundingBox();
        //bb.origin = m_pParent->convertToWorldSpace(bb.origin);

        if (bb.containsPoint(touchLocation) && m_pTableViewDelegate != NULL)
        {
            m_pTableViewDelegate->tableCellUnhighlight(this, m_pTouchedCell);
            m_pTableViewDelegate->tableCellTouched(this, m_pTouchedCell);
        }

        m_pTouchedCell = NULL;
    }

    CCScrollView::ccTouchEnded(pTouch, pEvent);
}
原文地址:https://www.cnblogs.com/lan0725/p/3504204.html