zoukankan      html  css  js  c++  java
  • 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);
    }
  • 相关阅读:
    leetcode 21 Merge Two Sorted Lists
    leetcode 20 Valid Parentheses
    leetcode 19 Remove Nth Node From End of List
    [学习笔记]守护进程深入理解
    [学习笔记]父进程wait和waitpid
    [学习笔记]进程终止的5种方式
    [学习笔记]父子进程共享文件描述符理解
    [学习笔记]Vfork深入理解
    [学习笔记]_exit和exit深入理解
    [学习笔记]孤儿进程僵死进程
  • 原文地址:https://www.cnblogs.com/lan0725/p/3504204.html
Copyright © 2011-2022 走看看