title: Per-Pixel collision code
body: <p>I tried to understand the code that checks the collision between two objects in the game - per pixel collision. The code is:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Determines if there is overlap of the non-transparent pixels
  /// between two sprites.
  /// &lt;/summary&gt;
  /// &lt;param name="rectangleA"&gt;Bounding rectangle of the first sprite&lt;/param&gt;
  /// &lt;param name="dataA"&gt;Pixel data of the first sprite&lt;/param&gt;
  /// &lt;param name="rectangleB"&gt;Bouding rectangle of the second sprite&lt;/param&gt;
  /// &lt;param name="dataB"&gt;Pixel data of the second sprite&lt;/param&gt;
  /// &lt;returns&gt;True if non-transparent pixels overlap; false otherwise&lt;/returns&gt;
  static bool IntersectPixels(Rectangle rectangleA, Color[] dataA,
                              Rectangle rectangleB, Color[] dataB)
  {
      // Find the bounds of the rectangle intersection
      int top = Math.Max(rectangleA.Top, rectangleB.Top);
      int bottom = Math.Min(rectangleA.Bottom, rectangleB.Bottom);
      int left = Math.Max(rectangleA.Left, rectangleB.Left);
      int right = Math.Min(rectangleA.Right, rectangleB.Right);
  
      // Check every point within the intersection bounds
      for (int y = top; y &lt; bottom; y++)
      {
          for (int x = left; x &lt; right; x++)
          {
              // Get the color of both pixels at this point
              Color colorA = dataA[(x - rectangleA.Left) +
                                   (y - rectangleA.Top) * rectangleA.Width];
              Color colorB = dataB[(x - rectangleB.Left) +
                                   (y - rectangleB.Top) * rectangleB.Width];
  
              // If both pixels are not completely transparent,
              if (colorA.A != 0 &amp;&amp; colorB.A != 0)
              {
                  // then an intersection has been found
                  return true;
              }
          }
      }
  
      // No intersection found
      return false;
  }
  </code></pre>
  
  <p>I found some explanations but no one explained the last lines:</p>
  
  <pre><code>// If both pixels are not completely transparent,
  if (colorA.A != 0 &amp;&amp; colorB.A != 0)
  {
      // then an intersection has been found
      return true;
  }
  </code></pre>
  
  <p>what is this <code>colorA.A</code> property? why this if-statement determine that a collision occured?</p>