On Mon, Aug 3, 2009 at 9:53 AM, quano<[email protected]> wrote:
>
> I recently also asked this in the iphone forum (http://www.cocos2d-
> iphone.org/forum/topic/1078), but I'm also curious how to do this with
> the standard cocos2d lib.
>
> So anyway...
>
> How do you detect if a user is clicking or dragging a specific sprite?
> I see that the layers attach themselves as handlers at director.window
> (director.window.push_handler(self)), but these events are global. If
> you do this on a sprite, and define a handler (for example
> on_mouse_press), even though you're not actually clicking on the
> sprite, you'll still get an event. So, how do you make it so that a
> sprite only gets events if the user is clicking it specifically?

You have two issues here:
1- doing the transformations to the point into layer space
2- cheking if the point is inside the sprite.

1 can be done with regular matrix operations. im planning of adding
that into cocos2d, as many users find the need for it.
2 can be something like checking for distance or whatever function you
like. this is really up to the type of sprite you have. maybe having
an interface for this would be helpful.

Lucio

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to