I have been trying to figure out a way to do sprite overlap detection in Godot 3.
Answers to a previous question of mine recommended that I content myself with bounding rectangles or polygons. Stubbornly, I am still pursuing the dream of sprite overlap detection.
I was spoiled by Pygame, which has a simple method to create masks from sprites, and then check them for overlap using a
Godot doesn't have anything like this built in, but it should still be possible to do it in the engine.
I discovered that
Textures have a
get_data() method which returns an
Images have a
get_pixel()method which returns the color data of each pixel in the image. Here is a link to the documentation on
I was thinking that it should be possible to use this data to construct a mask, whose coordinates can then be translated to world space. Once we have this, we can easily test if two masks overlap. And voila, sprite overlap detection!
The problem is that I don't know how to implement this.