Animated sprites clickable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By segei
:warning: Old Version Published before Godot 3 was released.

I would like to make animated sprites clickable. They all would have different shapes and be animated.
I tried to add an area2d and then a collision shape, but it’s not appropriated to an animated sprite.
Is there a simple way to detect a mouse click on an animated sprite, like an area that would fit to the original moving shape of the sprite ?

:bust_in_silhouette: Reply From: eons

Never did it myself but I guess you will need the Image data of each frame and try to guess which pixel was touched (zoom and scaling may affect some calculations), is not simple and maybe not worth it.

What is usually do is just have rough hitboxes and (if needed) apply some bias defined for each frame to decide if the click is valid or not, is not perfect but perfection is a great game experience killer.

With Areas, you have the option to have many shapes too, then just check clicks and validate the event if shape matches the current frame (I think overlapping shapes will all get a click event).

Thanks for your answer. I guess I’ll do it the most simple way.

segei | 2017-07-05 23:12