Cocos code ide touches,mouse 消息不响应

cocos code ide 好像对touches, mouse 代码不响应

试了测试代码,以及 js-moonwarriors (游戏中飞机不能移动)

测试代码:

    if( 'mouse' in cc.sys.capabilities ) {
        cc.eventManager.addListener({
             event: cc.EventListener.MOUSE,
            onMouseDown: function(event){
                var pos = event.getLocation(), target = event.getCurrentTarget();
                if(event.getButton() === cc.EventMouse.BUTTON_RIGHT)
                    cc.log("onRightMouseDown at: " + pos.x + " " + pos.y );
                else if(event.getButton() === cc.EventMouse.BUTTON_LEFT)
                    cc.log("onLeftMouseDown at: " + pos.x + " " + pos.y );
                target.sprite.x = pos.x;
                target.sprite.y = pos.y;
            },
            onMouseMove: function(event){
                var pos = event.getLocation(), target = event.getCurrentTarget();
                cc.log("onMouseMove at: " + pos.x + " " + pos.y );
                target.sprite.x = pos.x;
                target.sprite.y = pos.y;
            },
            onMouseUp: function(event){
                var pos = event.getLocation(), target = event.getCurrentTarget();
                target.sprite.x = pos.x;
                target.sprite.y = pos.y;
                cc.log("onMouseUp at: " + pos.x + " " + pos.y );
            }
        }, this);
    } else {
        cc.log("MOUSE Not supported");
    }

测试了mac,ios 模拟器,web上没有问题

又测试了一下moonwarriors

  1. mac 模拟器
    mac 模拟器上对鼠标操作没有任何响应(addListener时是正常的,就是鼠标消息没有响应)
  2. android 手机
    touch消息响应,只是有个bug
    JS: /data/data/org.cocos2dx.PrebuiltRuntimeJs/files/debugruntime/src/GameLayer.js:137:TypeError: touch.getID is not a function
    把 if (this.prevTouchId != touch.getID()) 改为
    if (this.prevTouchId != touch.getId())
    就能正常
  3. ios模拟器
    touch消息响应,只是有个bug
    JS: /data/data/org.cocos2dx.PrebuiltRuntimeJs/files/debugruntime/src/GameLayer.js:137:TypeError: touch.getID is not a function
    把 if (this.prevTouchId != touch.getID()) 改为
    if (this.prevTouchId != touch.getId())
    就能正常

在mac 中 if( ‘mouse’ in cc.sys.capabilities ) 成立,但实际是只响应touch
moonwarriors 中

gamelayer.js
init:function () 中,注释掉mouse 部分。 touches部分改为如下部分,就能正常移动

        //if (cc.sys.capabilities.hasOwnProperty('touches')){
            cc.eventManager.addListener({
                prevTouchId: -1,
                event: cc.EventListener.TOUCH_ALL_AT_ONCE,
                onTouchesMoved:function (touches, event) {
                    var touch = touches;
                    if (this.prevTouchId != touch.getId())
                        this.prevTouchId = touch.getId();
                    else event.getCurrentTarget().processEvent(touches);
                }
            }, this);
        //}

确实有问题, init:function () 中,注释掉mouse 部分。
确实和楼主说的一样,在cocos code ide里面确实存在这样的问题