博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CCLayer注册lua回调函数setTouchPriority失效
阅读量:4215 次
发布时间:2019-05-26

本文共 1947 字,大约阅读时间需要 6 分钟。

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);        }    }}

转载地址:http://yqsmi.baihongyu.com/

你可能感兴趣的文章
photoshop cc2019快捷键
查看>>
pycharm2019版本去掉下划线的方法
查看>>
九度OJ 1091:棋盘游戏 (DP、BFS、DFS、剪枝)
查看>>
leetcode 13: Roman to Integer
查看>>
a标签中调用js方法
查看>>
js函数中传入的event参数
查看>>
[hive]优化策略
查看>>
c++14现代内存管理
查看>>
右值引用,move语义和完美转发
查看>>
c++使用宏检测类是否包含某个函数或者变量属性
查看>>
CSS之Multi-columns的column-gap和column-rule
查看>>
CSS之Multi-columns的跨列
查看>>
CSS之浮动(一)
查看>>
CSS之浮动(二)
查看>>
AtomicInteger源码解析
查看>>
CopyOnWriteArraySet源码学习
查看>>
Openfiler 配置 NFS 示例
查看>>
Oracle 11.2.0.1 RAC GRID 无法启动 : Oracle High Availability Services startup failed
查看>>
Oracle 18c 单实例安装手册 详细截图版
查看>>
Oracle Linux 6.1 + Oracle 11.2.0.1 RAC + RAW 安装文档
查看>>