This project has moved and is read-only. For the latest updates, please go here.

Resolution Independence

Topics: Developer Forum, User Forum
Nov 12, 2010 at 12:22 AM

Hi again,

Thanks for all the support so far, I'm getting along great with the API.

I'm at a stage where I need to make my game resolution independent, so that no mater what resolution the game is viewed at, the game scales accordingly.

At the moment I'm using the method on riemers xna tutorial website to do this.

At the moment I can scale the textures according to the resolution.

The problem I'm having, is my fixtures. I can scale the textures but not the bodys of the fixtures. Can you scale fixtures after creation.

And if not what way would you go about insuring resolution independence.

Thanks for your help


Gerard Downes

Nov 12, 2010 at 12:35 AM
Edited Nov 12, 2010 at 12:35 AM

I just read this post by GenBox which helps


It says I should scale my vertices, but how do you scale the verts on a fixture ?

Nov 12, 2010 at 1:03 AM
Edited Nov 12, 2010 at 1:08 AM

You can scale the vertices on a fixture by calling vertices.Scale(), before you create the fixture, but I dont think you should in this case.

Resolution independence only affects the graphics, so you only need to scale the sprites. Also changing fixture sizes will make the engine act differently.
I think the best way to do this is probably passing a scaling matrix in spritebatch.Begin(). The scale amount should be the x/x or y/y like genbox did in the above thread.

I work with vertexbuffers and matrices so its much easier, as the projection matrix automatically does it, and I don't need any unit scaling at all.

EDIT: I just read the riemers tutorial, and I see it passes a matrix in spritebatch.begin(). That should work without needing to change the fixtures, are you having any issues with it?

Nov 12, 2010 at 9:15 AM
Edited Nov 12, 2010 at 9:23 AM

I create my fixtures and my textures in  LoadContent( ), with my textures and fixtures scaled to match up to each other.

Then before drawing I scale the textures to match the resolution.

But I can't scale my fixtures to match, meaning that my textures are smaller or bigger than my fixture and don't match up.

You talk about not scaling the fixture as it might cause problems, but what other options do I have, you can't scale one without scaling the other because then they don't match up, or can you ?

Thanks for your feedback

Nov 13, 2010 at 5:23 AM

Are you still using the riemers tutorial? In that case you shouldn't need to scale the fixtures to match the resolution, only to pass a scale-matrix by spritebatch.begin(). Imagine it as a camera zooming in and out. The zoom (scale matrix) makes objects look bigger and smaller, but their actual size doesnt change.

To scale the fixtures for another reason though, you would need to do something like to this:

//create the vertices
Vertices vertices = PolygonTools.CreateRectangle(1.0f, 1.0f);

//scale the vertices to half their original size
Vector2 scale = new Vector2(0.5f, 0.5f);
vertices.Scale(ref scale);

//create the shape and fixture
PolygonShape shape = new PolygonShape(vertices);
Fixture fixture = body.CreateFixture(shape);

I'm not sure what method you use to create the fixtures, but you need to scale the vertices before creating the shapes.

Nov 13, 2010 at 6:02 PM

Thanks Robert,

Your advice  helped alot, I final worked it out, my game is now resolution independent

Thanks again

Gerard Downes