How to check for pixel overlap between sprites?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diet Estus

I am trying to check for pixel-perfect overlap between my Player sprite and Enemy sprites.

Because this kind of thing is computationally expensive, I only do it if the bounding boxes of the sprites intersect.

After I check for bounding box intersection, how do I go about checking for sprite overlap?

In Pygame, you can create masks for each sprite and check for overlap using a simple collide_mask() method. Does Godot have something similar? I saw nothing like this in the sprite class.

:bust_in_silhouette: Reply From: DodoIta

I’m not sure if you can do that by using just a Sprite node, but you can use an Area2D, then add a Sprite as its child along with a CollisionShape. The Area2D node emits a signal if another Area or a physic body overlaps.
The drawbacks are that it is more expensive than just using a Sprite and I don’t know if it would be pixel accurate.