Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What's the correct technique for getting smooth sprite translations with XNA?

I've been developing the WP7 version of an app for a startup, so when we heard Angry Birds got ported today we wanted to check it out and compare. Angry Birds on WP7 had the sub-pixel blur problem with the bird sprites, whereas iPhone, Android, and Chrome all had smooth movement.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

It sounds like they are accidentally rounding their sprite positions to the nearest pixel. This can happen automatically if you use the SpriteBatch.Draw() call that takes a Rectangle as the position of the sprite, since XNA's Rectangle uses integers instead of floats to represent position.

If sprites are drawn with integer coords, then sub-pixel rendering will not occur, and sprites will appear to snap from one pixel position to the next, instead of blending smoothly between them.

share|improve this answer
    
That explains why, would the assumption for a fix then be to use the overload that accepts a Point()? –  Nate Jun 30 '11 at 5:06
    
You mean a Vector2, and yes. And to make sure that the floating point coordinates in the Vector2 struct are not being rounded to an integer value! –  Olhovsky Jun 30 '11 at 6:11
    
Snapping to the nearest pixel can however make for a clearer image, for example when using SpriteFonts, however this I only tested on Windows. –  Jonathan Connell Jun 30 '11 at 8:17
    
It's difficult to tell exactly whether the blur is occurring because of the sub-pixel rendering or because of the perceived blur from snapping to pixels. Which one actually results in the clearer image, at least in the context of little sprites on a cell phone screen flying around with Box2D physics? –  michael.bartnett Jun 30 '11 at 14:00
    
Haha, yes. Can you tell I was working in a different .NET stack, where its Point instead of Vector2? –  Nate Jun 30 '11 at 14:51

It could have to do with the framerate or it could have to do with the fact that xna does sub pixel rendering

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.