Android 在使用浏览器[cocos2d JS]时触摸设备不工作
我用cocos2djs制作了这个游戏,我在浏览器上试用了一下,它运行得很好,所有的触摸功能都在工作,但是当我把它编译到安卓设备上时,触摸功能根本不工作 我将触摸注册为: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
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);
}
这救了我!我看到的其他触摸事件不起作用,但这确实起作用了!