ok. I will try to manage the mouse_events from layers. Layers are then a kind of event manager then.
But sometimes, it does not seems the most natural way to handle things. Maybe I am wrong, but I use Layers when I need to place my sprites in all the window. That means that the (0,0) is the one from the window. Sometimes, I have a more complex stack of Sprites (like a spaceship made of many components). It's then, sometimes, more natural to positionned each Sprite relative to another origin (spaceship center). Not the (0,0) of the window. So, I subclass Sprite, and fill it with other Sprites. Then, I come in the case when it's also more natural to handle mouse_event in that Sprite class instead of the parent Layer. Is there a good way to handle mouse_event in a Sprite ? Seems that even if in the on_exit I pop_handlers, the sprite still receives it. Is there a more explicit way to remove an handler from my Sprite, in the on_exit ? better than director.window.pop_handlers() as for Issue 163, I totally agree with it. The natural way seems more to be from front to back. by the way, how can I help improving cocos2D ? I do not have 8 hours per day for it, but I can spend some time. On Feb 28, 11:55 pm, claudio canepa <[email protected]> wrote: > On Tue, Feb 28, 2012 at 5:33 PM, Philippe <[email protected]> wrote: > > I would be more in a case with several levels, so, a scene per level. > > > here is a code > >http://pastebin.com/kc4PLGC0 > > > If I click, the event will be receive by layer1 and my first sprite. > > I get the following output > > > [Layer1] on_mouse_press > > [MySprite] on_mouse_press 1 > > > then, it replaces the scene. > > if I click again, I get > > > [Layer2] on_mouse_press > > [MySprite] on_mouse_press 2 > > [MySprite] on_mouse_press 1 > > > The event it still handled by the sprite from scene1. layer1 behave > > well. Only issue with the sprite. > > I see the same. > > 1. I think that while not clearly stated in the docs the event handling > nodes should be Layers or Scenes: > CocosNode class has no event functionality > Scene and Layer inherits from scene.EventHandlingMixin > > 2. event handling code in cocos is under-designed under-coded; they are > others issues related > (seehttp://code.google.com/p/los-cocos/issues/detail?id=163) > > 3. I'm in a hurry now but I will be glad to discuss what will be a sane > event handling for cocos. > > By the way, I always post the samples (if too long) to pastebin, is it > > > find ? do people prefer that we post everything in the message ? > > pastebins are fine > > claudio > > -- -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cocos-discuss?hl=en.
