In that messageLayer I've placed a Menu. When one of the MenuItems is activated, a callback is excecuted and the layer automatically dissapears. That's all right.
But for some reason, the gameLayer registers a onMouseUp event, while it should have been swallowed when the MenuItem was activated.
Upon inspection of the classes, I've discovered that the actual touch/mouse interaction is done in "CCMenu.js", where both onMouseUp and onTouchEnded trigger the following:
<pre> onTouchEnded:function (touch, e) {
if(this._state !== cc.MENU_STATE_TRACKING_TOUCH){
cc.log("cc.Menu.onTouchEnded(): invalid state");
return;
}
if (this._selectedItem) {
this._selectedItem.unselected();
this._selectedItem.activate();
}
this._state = cc.MENU_STATE_WAITING;
}</pre>
Now, I have tried to add a "return true;" to that method, but it's not achieving the desired effect (the click is still propagating).
For now, in my game, I've settled for using a flag that I set to "true" when I show my messageLayer and, in my gameLayer's onMouseUp event do nothing but setting it to "false" if it was true, therefore discarding the propagated click, but this could be quite troublesome in the future.
I have a layer, let's call it "messageLayer", above my "gameLayer", that swallowes (stops the propagation of) touches correctly as was discovered in this thread: http://cocos2d-x.org/forums/19/topics/42588?r=42691#message-42691
In that messageLayer I've placed a Menu. When one of the MenuItems is activated, a callback is excecuted and the layer automatically dissapears. That's all right.
But for some reason, the gameLayer registers a onMouseUp event, while it should have been swallowed when the MenuItem was activated.
Upon inspection of the classes, I've discovered that the actual touch/mouse interaction is done in "CCMenu.js", where both onMouseUp and onTouchEnded trigger the following:
<pre> onTouchEnded:function (touch, e) {
if(this._state !== cc.MENU_STATE_TRACKING_TOUCH){
cc.log("cc.Menu.onTouchEnded(): invalid state");
return;
}
if (this._selectedItem) {
this._selectedItem.unselected();
this._selectedItem.activate();
}
this._state = cc.MENU_STATE_WAITING;
}</pre>
Now, I have tried to add a "return true;" to that method, but it's not achieving the desired effect (the click is still propagating).
For now, in my game, I've settled for using a flag that I set to "true" when I show my messageLayer and, in my gameLayer's onMouseUp event do nothing but setting it to "false" if it was true, therefore discarding the propagated click, but this could be quite troublesome in the future.