Projects > cpp > Issues > Bug #371

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

A layer can't registered as a StandardTouchDelegate when touch event is handling

Bug #371 [Closed]
zhangbin@cocos2d-x.org 2011-03-01 19:40 . Updated over 4 years ago

If a layer is touch enabled and you want show it when a menu item clicked.
Then it’s not registered as a StandardTouchDelegate,but a TargetedTouchDelegate.

The code which cause the bug is in CCTouchDispatcher.cpp, line 372:

    if (m_bToAdd)
    {
        m_bToAdd = false;
        NSMutableArray::NSMutableArrayIterator iter;
         CCTouchHandler *pHandler;
        for (iter = m_pHandlersToAdd->begin(); iter != m_pHandlersToAdd->end(); ++iter)
        {
            pHandler = *iter;
            if (! pHandler)
            {
                break;
            }

            if (pHandler->getDelegate()->getTouchDelegateType() & ccTouchDelegateTargetedBit)     // The code cause the bug.
            {               
                forceAddHandler(pHandler, m_pTargetedHandlers);
            }
            else
            {
                forceAddHandler(pHandler, m_pStandardHandlers);
            }
        }

        m_pHandlersToAdd->removeAllObjects();   
    }

The return value of code “pHandler->getDelegate()->getTouchDelegateType() & ccTouchDelegateTargetedBit” is always true.So the layer is register as a TargetedTouchDelegate.

walzer@cocos2d-x.org 2011-03-05 00:12
  • Target version set to 9
zhangbin@cocos2d-x.org 2011-03-23 18:27
  • Subject changed from A bug of CCTouchDelegate to A layer can't registered as a StandardTouchDelegate when touch event is handling
zhangbin@cocos2d-x.org 2011-04-24 18:29
  • Category set to 5
  • Status changed from New to Closed

Have been fixed in issue #467.

walzer@cocos2d-x.org 2011-04-24 18:56
  • Assignee set to walzer@cocos2d-x.org
  • Target version changed from 9 to cocos2d-0.99.5-x-0.8.3
walzer@cocos2d-x.org 2012-05-25 08:15
  • Project changed from cocos2d-x to cpp
  • Category deleted (5)
  • Target version deleted (cocos2d-0.99.5-x-0.8.3)

Atom PDF

Status:Closed
Start date:2011-03-01
Priority:Normal
Due date:
Assignee:walzer@cocos2d-x.org
% Done:

0%

Category:-
Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.