Cocos creator touch event single point and multi-point pit

Cocos creator does not have a global switch for multi-point single-touch, so when doing button touch, it is often necessary to use code to achieve single-point touch.
Browsing the forum, I found a way to implement it, which is to call the getID() interface in the event of the touch event to determine whether the id of the current event is 0. If it is, it indicates the current event, if not, it indicates the second touch event, just return.
In other words, the touch event ID of cocos creator is assigned from zero.
This is normal in the preview in the browser and in the WeChat debugging tool, and it is also normal in Android. But on the ios device, there is a problem. After the log breakpoint, it is found that the touch event ID of the ios device does not start from zero, but a large number. This caused this implementation method to fail on ios.
When you meet today, write it down.

Supongo que te gusta

Origin blog.csdn.net/weixin_36760331/article/details/103167937
Recomendado
Clasificación