Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在使用浏览器[cocos2d JS]时触摸设备不工作_Android_Cocos2d X_Cocos2d Js - Fatal编程技术网

Android 在使用浏览器[cocos2d JS]时触摸设备不工作

Android 在使用浏览器[cocos2d JS]时触摸设备不工作,android,cocos2d-x,cocos2d-js,Android,Cocos2d X,Cocos2d Js,我用cocos2djs制作了这个游戏,我在浏览器上试用了一下,它运行得很好,所有的触摸功能都在工作,但是当我把它编译到安卓设备上时,触摸功能根本不工作 我将触摸注册为: cc.eventManager.addListener({ event: cc.EventListener.TOUCH_ONE_BY_ONE, setTouchEnabled: true, setSwallowTouches: true, onTou

我用cocos2djs制作了这个游戏,我在浏览器上试用了一下,它运行得很好,所有的触摸功能都在工作,但是当我把它编译到安卓设备上时,触摸功能根本不工作

我将触摸注册为:

        cc.eventManager.addListener({
        event: cc.EventListener.TOUCH_ONE_BY_ONE,
        setTouchEnabled: true,
        setSwallowTouches: true,
        onTouchBegan: this.onTouchBegan,
    }, this)
并通过以下方式实施:

onTouchBegan:function(touch, event){
    var pos = touch.getLocation();
    var touch_x = pos.x;
    var touch_y = pos.y;
...
}

我是这样实现的,它在WEB、Android和iOS中运行良好:

if( 'touches' in cc.sys.capabilities ) { 
    this._touchListener = cc.EventListener.create({
        event: cc.EventListener.TOUCH_ALL_AT_ONCE,
        onTouchesBegan: function(touches, event) {

        },

        onTouchesMoved: function(touches, event) {

        },

        onTouchesEnded: function(touches, event) {

        }
    });

    cc.eventManager.addListener(this._touchListener, this);
}

这救了我!我看到的其他触摸事件不起作用,但这确实起作用了!