How to set swallowtouches:false officially in Cocos Creator?

How to set swallowtouches:false officially in Cocos Creator?
0

#1

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.

So could you teach me how to set the swallowtouches:false officially?

Regards,


#2

Same question here. Does anyone know about this?


#3

I tried looking here: https://docs.cocos2d-x.org/creator/api/en/classes/Event.EventTouch.html
but I don’t see anything.

Let us ask @Big_Bear for help.


#4

Reference:https://docs.cocos2d-x.org/creator/manual/en/scripting/events.html
use event.stopPropagation to stop the event delivery.
and you can use BlockInputEvents component to stop touch event easily


#5

Hi,

Thank you for your reply.

The behavior of event.stopPropagation and BlockInputEvents are not the same with swallowtouches:false.
So could you consider that make swallowtouches selectable true/false with on method’s argument or any other way ?