Pixel perfect collision is hard. I got it to working after a lot of pain. Why do you need it?
–
ashes999May 29 '12 at 20:53

Because my sprites have transparent areas, it works perfectly with still sprites but when it's animated it doesn't do anything. I already have a check for rectangle collision first and if that's true it goes to pixel detection.
–
JixiMay 29 '12 at 20:56

From what I recall, the main problem was that the TextureData refers to the non-scaled, non-rotated image; you need to modify it accordingly (or iterate accordingly over the right area) to get pixel perfect collision.
–
ashes999May 29 '12 at 21:14

What does Vector2 pos do? It's never touched in your small IntersectPixels.
–
HackworthMay 29 '12 at 21:36

Sorry about that, forgot to update it into it.. it's there to prevent the sprite for getting stuck, it's the movement speed of the sprite. Updating the question
–
JixiMay 29 '12 at 21:59

What you are currently taking as the collision rectangle is the source rectangle, the rectangle that tells you which part of the sprite sheet you want to draw for your current animation frame, which has nothing to do with your object's position:

You also add a Vector2 pos, which you described in the comments as the object velocity vector, which would make even less sense; though by the name pos I guess you meant the right thing, the position vector, the object's location.

So you got it half right: the mistake was that you added that position vector to the sprite sheet source rectangle (which has varying X and Y values), instead of the object's dimensions (which, expressed as a rectangle, always has position (0, 0)).

Assuming your default, non-animated source rectangle is located at (0, 0) on the sprite sheet, it would explain why collision is working when not animated, because you happen to have a rectangle with the correct location, i.e. (0, 0). But as soon as you start animating, the X and Y coordinates are wrong, because you always need (0 + pos.X, 0 + pos.Y), but you get something other than 0, depending on your currentFrame and frameRow.

Exactly what i started doing a moment ago ^^ collisionRect = new Rectangle((int)me.Position.X, (int)me.Position.Y, me.Texture.Width / (int)((me.frameCount - 1) * me.TextureWidth), me.Texture.Height); Now that almost works, it has some weird problems with getting the correct height position of the obstacle, even when using a single row spritesheet.(half of the block is above the block as an invisible block and half of the bottom is missing, like it moved 50% up). Once i figure that out it's pretty much perfect. Edit. and yeah the pos is a temporary position modifier.
–
JixiMay 29 '12 at 22:27

@Jixi If I answered your original question, consider an upvote and accept.
–
HackworthMay 29 '12 at 22:39

Sadly i can't upvote yet =( I'll definitely accept it though once i get it 100% functiona =)
–
JixiMay 29 '12 at 22:50