creator 版本 2.0.8
现在我需要在同级节点上实现事件穿透,在论坛上找到下面的代码:
const { ccclass, menu } = cc._decorator;
/** 疏通输入事件,该组件要放在包含监听触摸事件组件的后面 /
@ccclass
@menu(“i18n:MAIN_MENU.component.ui/Unchoke Input Events”)
export default class UnchokeInputEvents extends cc.Component {
/* 是否吞噬事件 */
private _isSwallow: boolean = false;
onEnable() {
if (this.node._touchListener) {
this.node._touchListener.setSwallowTouches(this._isSwallow);
}
}
}
试了也有用,但是上面的代码是作为一个组件来实现,有没有办法用代码直接实现?