This.setMouseEnabled is not a function

Hi,
When I run my JSB project in a browser, it works well. But when I launch it with a native app, I get this error message:

cocos2d: JS: .....HexGrid.js:25:TypeError: this.setMouseEnabled is not a function

What can I do, or check, to solve this ?

Thanks for your help

Maybe there is not mouse in native. Try to check it in sys.capabilities.

Hi,

i have the same problem.

i use Cocos Code IDE on Windows x64 and develop for android.

Unfortunately it says that this.setMouseEnabled, this.setKeyboardEnabled and this.setTouchEnabled is not a function.

What’s wrong there?

This is my code:

var MainLayer = cc.Layer.extend({

_player:null,

ctor:function() {
         this._super();

cc.associateWithNative( this, cc.LayerColor );

this.init();
     },

init:function(){
         if( ‘mouse’ in sys.capabilities ) {
             this.setMouseEnabled(true);
         } else {
             cc.log(“MOUSE Not supported”);
         }
         return true;
     },

onEnter:function () {
         this._super();
         this._player = cc.Sprite.create(s_player);

if( ‘touches’ in sys.capabilities ) {
             this.setTouchEnabled(true);
         }
         if( ‘mouse’ in sys.capabilities ) {
             this.setMouseEnabled(true);
         }

// background image
         var bg = cc.Sprite(img_bg);
         bg.setPosition(cc.winSize.width / 2, cc.winSize.height / 2);
         this.addChild(bg);

// player
         //var player = cc.Sprite.create(s_player);
         this._player.setPosition(cc.winSize.width / 2, cc.winSize.height / 2);
         this.addChild(this._player);

},

onMouseDown:function(event) {
         var pos = event.getLocation();
         logTest("onMouseDown at: " + pos.x + " " + pos.y );
         this.sprite.setPosition( pos );
     }

});

MainLayer.create = function () {
     var sg = new MainLayer();
     if (sg && sg.init(cc.c4b(255, 255, 255, 255))) {
         return sg;
     }
     return null;
};

MainLayer.scene = function () {
     var scene = cc.Scene.create();
     var layer = MainLayer.create();
     layer.init();
     scene.addChild(layer);
     return scene;
};

Thanks in Advance ;).