Is there a way to receive touch event from button?

Hi, everyone
I have a OnTouchController attract to canvas to receive TOUCH_START event and instantiate particle system at touchLocation.

But when I touched button the button not propagation TOUCH_START event to canvas(parent). Is there a way to workaround this?

This is button script that stopPropagation. (cocos-engine/CCButton.js at 9428f94afbf93f2f36ce540c15740bc19e96d4ac · cocos/cocos-engine · GitHub)

Hi @armariya
Normally you should customize engine code and build it for your project but it’s not so easy and quick way. Another solution is that y you can re-define functions on the fly in javascript.
I’ve recorded video tutorial for your subject here:

It shows how to redefine button’s _onTouchBegan function during scene load.
Hope it helps :wink:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Thank you, you’re amazing!

1 Like