I'm using a spritesheet animation in XNA and I want to use pixel perfect collision. My problem is that the pixel perfect collisions checks if the current pixel on the spritesheet is transparent instead of checking against the part of the spritesheet i'm using. This is my code:
blockTextureData = new Color[shot.texture.Width * shot.texture.Height];
shot.texture.GetData(blockTextureData);
personTextureData = new Color[player2.texture.Width * player2.texture.Height];
player2.texture.GetData(personTextureData);
if (IntersectPixels(player2.CollissionBox, personTextureData, shot.CollissionBox, blockTextureData))
I'd like to know how to choose a specific part of the spritesheet and check collision against it. I used this MSDN guide.
EDIT: I managed to figure it out, i used this instead
src = new Rectangle(frame, 0, 87, 100);
player.texture.GetData<Color>(0, src, personTextureData,0, 87*100);
and frame is were you start it, e.g 0
for the first and 87
for the second since i use a spritesheet with 2 pictures wich is 2*87
in width and 100
in height.
Edit2: The problem now is that once you hit the pixelperfect will stop working, so it only works for 1 hit.