Searching in the forum i saw some old posts dealing with the same problem , unfortunately it doesn’t help much.
I have 2 layers loaded using cc.LayerMultiplex
first layer contains Menuitem , when i click it the callback doing switchTo(1) which is the game layer
The click get passed under to the Game Layer . where : onMouseUp: function(event){ }
How to prevent it ?
Is there any way to calback when Sprite done loading ?
Here is my sample code :
var LayerController = cc.Layer.extend({
ctor:function () {
this._super();
return true;
},
onEnter:function () {
this._super();
var logInlayer = new LogInlayer();
var gameLayer = new GameLayer();
var layer = new cc.LayerMultiplex(logInlayer,gameLayer);
this.addChild(layer, 0);
}
});
var loginSprite = null;
var LogInlayer = cc.Layer.extend({
winsize:null,
ctor:function () {
this._super();
this.winsize = cc.winSize;
return true;
},
onEnter:function () {
this._super();
loginSprite = Login.initSprite();
loginSprite.x = this.winsize.width / 2;
loginSprite.y =this.winsize.height / 2;
this.addChild(loginSprite, 0);
}
});
var Login = cc.Sprite.extend({
Editbox:null,
ctor: function(){
this._super();
},
onEnter:function () {
this._super();
var LogIn_item = new cc.MenuItemFont("LogIn", this.onMenuLogInCallback,this);
var menu = new cc.Menu(LogIn_item);
menu.x = this.width/2;
menu.y = (this.height/2);
this.addChild(menu,1);
},
onMenuLogInCallback:function(sender){
this.parent.parent.switchTo(1);
}
});
Login.initSprite = function () {
var login = new Login();
return login;
};
var GameLayer = cc.Layer.extend({
sprite:null,
winsize:null,
ctor:function () {
//this._super();
this._super();
this.winsize = cc.winSize;
if ('touches' in cc.sys.capabilities){
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchesEnded:function (touches, event) {
var touch = touches[0];
}
}, this);
} else if ('mouse' in cc.sys.capabilities)
var listener1 = cc.EventListener.create({
event: cc.EventListener.MOUSE,
onMouseUp: function(event){
// Im getting the touch callback from the LOGIN layer here , when switchTo triggered
}
});
cc.eventManager.addListener(listener1, this);
this.schedule(this.gameLoop);
return true;
},
onEnter:function () {
this._super();
},
});