cocos2d-js安卓设备don't响应触摸事件,iOS和web确实可以处理触摸事件

cocos2d-js android devices don't respond to touch events, iOS and web does work with touch events

本文关键字:触摸 事件 web iOS 处理 响应 don cocos2d-js      更新时间:2023-09-26

我正在使用cocos2D JS将我的2D游戏移植到多个平台。

我遇到的问题是,每当我在安卓设备上运行和测试游戏时,它根本不会对触摸事件做出响应。使用完全相同的代码,我可以在iOS设备上构建和运行它,触摸也能正常工作。当我在网络上运行它时,触摸事件在iOS或android设备上运行良好。

这就是我实现触摸事件的方式:---------------

在主游戏中使用场景

(cc.Scene.extent({
onEnter: function(){
...
...
...
cc.eventManager.addListener({
    event: cc.EventListener.TOUCH_ONE_BY_ONE,
    setTouchEnabled: true,
    onTouchBegan: function(touch,event){
        // Do Stuff
        // Do More Stuff
    },
    .....
    .....
},this);

就像我说的,iOS和网络对这些触摸事件的反应很好,只是android设备没有。此外,鼠标事件在所有平台上都运行良好。

有什么想法吗?谢谢

有一个拼写错误:您应该使用cc.Scene.

中的extend