Hi,
I could set swallowtouches:false
when using cocos2d-x,
but it seems to be unavailable on recent CocosCreator.
I’d like to set touchEvent to touchNode with propagation, touched point.
But if using on
or once
, swallowtouches is always true.
So I use cc.EventListener
and cc.eventManager
to make it.
let listener1 = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: false,
onTouchBegan: (touch: cc.Touch, event) => {
return true;
},
onTouchEnded: (touch: cc.Touch, event) => {
// do something with propagation
}
});
cc.eventManager.addListener(listener1, this.touchNode);
But EventListener and eventManager are private,
and there is warn below when running.
Simulator: JS: [WARN]: The 'cc.eventManager' will be removed in v2.0, please use 'cc.EventTarget or cc.systemEvent' instead.
And not recommended to use cc.eventManager directly for Node.
- http://docs.cocos2d-x.org/creator/api/en/classes/Node.html#on
- It’s the recommended way to register touch/mouse event for Node,
please do not use cc.eventManager directly for Node.
So could you teach me how to set the swallowtouches:false officially?
Regards,