I tried to understand the code that checks the collision between two objects in the game - per pixel collision. The code is:
///
/// Determin
The Color.A property is the alpha-value of the color. 0
means completely transparent, and 255
means completely opaque.
If one of the colors is completely transparent at the specified pixel, there is no collision (because one of the objects is not at this place, but only its bounding box).
Only if both of them are != 0
, there actually are two objects at the same place and a collision has to be handled.
See for example this image:
The bounding boxes (black rectangles) intersect, but you would not consider it to be a collision between the red and yellow circle.
Therefore, you have to check the color at the intersecting pixels. If they are transparent (white in this example), the circles themselves are not intersecting.
This is why you have to check if the colors of the objects are transparent. If one of them is transparent, the object itself is not intersecting the other object, only its bounding box.