Hi folks! Im just discovering cocos2d with JavaScript and I want to play a little with mouse events. There’s my code:
var HelloWorldLayer = cc.LayerColor.extend({
sprite:null,
ctor:function () {
this._super();
this.init();
},
init:function () {
this._super();
var winsize = cc.director.getWinSize();
var centerPos = cc.p(320, 240);
var spriteBG = cc.Sprite.create(res.Bg_png);
spriteBG.setPosition(centerPos);
this.addChild(spriteBG);
var centerPos = cc.p(320, 100);
var spriteBG = cc.Sprite.create(res.Globo_png);
spriteBG.setPosition(centerPos);
this.addChild(spriteBG,1);
},
onMouseDown: function(event) {
alert('ok');
}
});
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new HelloWorldLayer();
this.addChild(layer);
}
});
MouseDown don’t work and if I add ( this.setMouseEnabled(true) I got and error…
anybody can help me?
thanks!