I have being playing around with the collision mask example to get a better understanding of how collision detection works and have come across the following behaviour, which I find confusing.
In the original code, the GetMaskID method is used as follows:
If i change the &spriterect; to NULL,
a valid mask ID is only returned when the right portion of the source surface comes in contact with a mask on the mask surface. That is to say, when the first 90x120 pixels of the source surface intersects with a mask, GetMaskID returns an invalid mask id. It is only when the last 80*120 pixels (right side) of the surface intersect with a mask that GetMastID returns a valid mask ID.
This doesn't make any sense to me. Could someone explain why this is happening?
Cheers,
Joe
In the original code, the GetMaskID method is used as follows:
- Code:
m_pCollisionSurface->GetMaskID(dwSpriteX, dwSpriteY, m_pPlantSurface, &spriterect;, &maskColor;, &maskIntersect;);
If i change the &spriterect; to NULL,
- Code:
m_pCollisionSurface->GetMaskID(dwSpriteX, dwSpriteY, m_pPlantSurface, NULL, &maskColor;, &maskIntersect;);
a valid mask ID is only returned when the right portion of the source surface comes in contact with a mask on the mask surface. That is to say, when the first 90x120 pixels of the source surface intersects with a mask, GetMaskID returns an invalid mask id. It is only when the last 80*120 pixels (right side) of the surface intersect with a mask that GetMastID returns a valid mask ID.
This doesn't make any sense to me. Could someone explain why this is happening?
Cheers,
Joe