- Creator 版本: 2.4
同层级的node点击事件默认是不穿透的,我看之前网上用this.node[’_touchListener’].setSwallowTouches(false);
这个方法来进行穿透,目前版本好像是用不了会报错?请问还有别的可用办法吗
同层级的node点击事件默认是不穿透的,我看之前网上用this.node[’_touchListener’].setSwallowTouches(false);
这个方法来进行穿透,目前版本好像是用不了会报错?请问还有别的可用办法吗
2.4.9 也可以用,没报错。
应该是可以用的。这个方法藏得比较深,一般人不告诉他。
Simulator: D/jswrapper (162): JS: [ERROR]: (see stack) Uncaught TypeError: Cannot read property ‘setSwallowTouches’ of null [0]Test.start@dst/assets/Script/99Test/Test.js:60
Simulator: [1]eval@(no filename):3
Simulator: [2]anonymous@src/cocos2d-jsb.js:27752
Simulator: [3]invoke@src/cocos2d-jsb.js:27702
Simulator: [4]startPhase@src/cocos2d-jsb.js:27852
Simulator: [5]mainLoop@src/cocos2d-jsb.js:17809
Simulator: [6]callback@src/cocos2d-jsb.js:18061
Simulator: [7]tick@jsb-adapter/jsb-builtin.js:2156
两种写法都试了,都报这个错
this.node[’_touchListener’].setSwallowTouches(false);
(this.node as any)._touchListener.setSwallowTouches(false);
是不是哪里写得不对?
之前都是测试的 web 平台。原生平台上还没试过。
你要先注册触摸事件,再设置
可以了,谢谢
该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。