CCLayer注册lua回调函数setTouchPriority失效
2015-05-26 17:59
531 查看
CCLayer注册lua回调函数setTouchPriority失效: 方式1、不行 touchLayer:setTouchPriority(-5000) touchLayer:registerScriptTouchHandler(touchLayerCallFunc) touchLayer:setTouchEnabled(true) maskLayer:addChild(touchLayer) 方式2、可以 touchLayer:registerScriptTouchHandler(touchLayerCallFunc, false, -5000, true) touchLayer:setTouchEnabled(true) maskLayer:addChild(touchLayer) 原因: void CCLayer::registerWithTouchDispatcher() { CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher(); // Using LuaBindings /* 我们使用registerScriptTouchHandler方法注册了回调,所以m_pScriptTouchHandlerEntry不为空: void CCLayer::registerScriptTouchHandler(int nHandler, bool bIsMultiTouches, int nPriority, bool bSwallowsTouches) { unregisterScriptTouchHandler(); m_pScriptTouchHandlerEntry = CCTouchScriptHandlerEntry::create(nHandler, bIsMultiTouches, nPriority, bSwallowsTouches); m_pScriptTouchHandlerEntry->retain(); } */ if (m_pScriptTouchHandlerEntry) { if (m_pScriptTouchHandlerEntry->isMultiTouches()) //多点触摸 { pDispatcher->addStandardDelegate(this, 0); LUALOG("[LUA] Add multi-touches event handler: %d", m_pScriptTouchHandlerEntry->getHandler()); } else //单点触摸 { //注意这里和C++的不同,这个的优先级和是否吞噬,都是CCTouchScriptHandlerEntry类中的成员变量, //也就是我们调用registerScriptTouchHandler方法传进来的值,而不是通过setTouchPriority方法设置 //的m_nTouchPriority成员变量,这个变量对于lua没用。 pDispatcher->addTargetedDelegate(this, m_pScriptTouchHandlerEntry->getPriority(), m_pScriptTouchHandlerEntry->getSwallowsTouches()); LUALOG("[LUA] Add touch event handler: %d", m_pScriptTouchHandlerEntry->getHandler()); } } else { if( m_eTouchMode == kCCTouchesAllAtOnce ) { pDispatcher->addStandardDelegate(this, 0); } else { //C++中调用优先级才会用到m_nTouchPriority变量,即可以通过setTouchPriority方法设置。 pDispatcher->addTargetedDelegate(this, m_nTouchPriority, true); } } }
相关文章推荐
- CCLayer的优先级设置函数setTouchPriority()不生效
- android listvieew PullToRefreshListView设置setOnTouchListener()失效
- cocos2d-x 2.2.0 如何在lua中注册回调函数给C++
- cocos2d-x 2.2.0 如何在lua中注册回调函数给C++
- cocos2d 2.0中 setTouchPriority无效的问题
- cocos2d-x 2.2.0 如何在lua中注册回调函数给C++
- cocos2d-x TestLua 之 设置菜单优先级 setHandlerPriority()
- LUA和C/C++交互-注册回调函数
- cocos2d中 各种setTouchPriority无效的问题
- TextView不能响应setOnTouchListener ACTION_DOWN的解决方法
- SetTimer and CreateWaitableTimer的例子(静态函数设置为回调函数,瑞士的网页,有点意思)
- stl的set,multiset, map, multimap, deque, list, stack, queue, priority_queue
- 17 API-集合(登录注册案例集合版,Set集合(Set_HashSet_TreeSet),Collection单列集合总结)
- jdbc-mysql基础 注册驱动 System.setProperty
- set_ideal_network和set_dont_touch_network
- GLUT-注册回调函数
- Android中EditView TextView (padding失效)使用setBackgroundDrawable或setBackgroundResource则xml中设置的 Padding失效
- Cocos2d-x Lua:Lua回调函数小结
- 线程优先级SetThreadPriority的使用
- cocos2d-lua09apk打包发布&C++注册到Lua