On May 10, 12:45 pm, Peter Enerccio <[email protected]> wrote:
> Hello
> one possible, but I am not sure if effective way would be translating
> the X, Y to the relative X Y of the sprite (ie relative to the sprite
> not the screen), then getting ImageData out of the sprite and checking
> the pixel against alpha value. If it is not 255, the sprite was
> clicked. But this might not be the fastest method.
>


I can't think of a better way - I don't have any reason to think if
would be faster to create a mask for each sprite, just to test
against.

Hopefully the speed shouldn't be an issue though. Don't forget to
first discard all sprites that don't come near the mouse cursor based
on rough-and-ready collision detection, such as axis-aligned bounding
boxes. So you're hopefully only executing this pixel-perfect detection
on just the small number of sprites that are currently overlapping the
mouse position.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" 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/pyglet-users?hl=en.

Reply via email to