2.3.3 同层级Node 如何让事件穿透到较低层级的物件

image

onLoad() {

    this.node.on(cc.Node.EventType.TOUCH_START, this.TouchStart, this);

    this.node.on(cc.Node.EventType.TOUCH_MOVE, this.TouchMove, this);

    this.node.on(cc.Node.EventType.TOUCH_END, this.TouchEnd, this);

    this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.TouchCancel, this);

    (this.node as any)._touchListener.setSwallowTouches(false);

}

想要做按钮事件穿透功能
爬文找到了
(this.node as any)._touchListener.setSwallowTouches(false);
这个方法
透过console.log检查时SwallowTouches的属性也确实为false
但是我仍然点击不到Button物件(该物件挂载的是cc.Button组件)
SwallowTouches好像不起作用
onLoad这个function的script则是挂在Slide物件上
拜託各路大神求解…

不管是 button 还是 slide 组件上的监听回调里都调用了event.stopPropagation(),你想穿透,得重写组件的方法。
比如:
image

好的 我再试试看
另外是这样的
slide这个node并没有用上slide组件
是挂上我自己写的script
写法就像我贴出来的那样

明明也应用了setSwallowTouches却不起作用
可以了解下这是什麽原因吗

你想点击 slide 也能点击 button,脚本应该挂在 slide 节点上