Per Pixel Collision - Code explanation

前端 未结 3 826
死守一世寂寞
死守一世寂寞 2021-01-14 19:37

I\'m currently trying to understand per pixel collision detection.

This is the code I don\'t understand:

static bool IntersectPixels(Rectangle rectan         


        
3条回答
  •  无人及你
    2021-01-14 20:32

    First up, it finds the region the two image rectangles intersect, then it iterates through each pixel in that region, and compares the alpha values of each image of each pixel. If neither has an alpha value of 0, they are both considered 'solid' and therefore colliding.

    enter image description here

提交回复
热议问题