+1 vote

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.

in Engine by (1,577 points)
edited by

1 Answer

0 votes

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.

by (563 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.