I want to support the following 4 resolutions in my Windows Phone 8 game: 480 × 800, 768 × 1280, 720 × 1280, 1080 x 1920. How can I do that with Monogame? If I draw a sprite with Monogame, the sprite is not drawn on the right place in every resolution. For example, with a resolution of 768 × 1280, the sprite is drawn in the center of the screen, but if I use another resolution, the sprite is no more drawn in the center of the screen.

What should I do so that the sprite is in every resolution on the same place?


1 Answer 1


You must resize all your image, and use some maths for positions.

I don't know XNA, but I will give you a code that you will adapt with this lib.


1. You will do everything based on 1 screen resolution, and scale your images, relative to this.

float Reference_Screen_X = 1280;
float Reference_Screen_Y = 720;

2. You will get your current screen resolution

float Screen_X = GetScreenWidth(); //your function to get the screen width
float Screen_Y = GetScreenHeight();

3. You will resize all your image this way

float size_x = image.getwidth() * ( Screen_X / Reference_Screen_X );
float size_y = image.getheight() * ( Screen_Y / Reference_Screen_Y );
image.setSize(size_x, size_y);

OR with scale methods

float scale_x = 1 * ( Screen_X / Reference_Screen_X );
float scale_y = 1 * ( Screen_Y / Reference_Screen_Y );
image.setScale(scale, scale);


4. You have to keep in mind that every value you will set, will be in a Reference_Screen coordinate.

For exemple if you want go to the middle of the screen :

image.x = 640 * ( Screen_X / Reference_Screen_X );


You should use global variables like :

  float refToScreen_x = ( Screen_X / Reference_Screen_X );
  float refToScreen_y = ( Screen_Y / Reference_Screen_Y );

Then you just multiply them to the number you want :

 x = 500 * refToScreen_x;

I hope this will help you.

  • \$\begingroup\$ This is a very complicated way of doing it. \$\endgroup\$ Commented Feb 1, 2014 at 2:36
  • 1
    \$\begingroup\$ @craftworkgames, this way is very simple, I just add the image scaling for him. If you have a simplier way, I would be glad to see it \$\endgroup\$
    – LeSam
    Commented Feb 1, 2014 at 2:44
  • \$\begingroup\$ Will my sprites always have the same proportions if I change the resolution? For example, I don't want that a circle looks oval on a different resolution. Which code should I use so that my circles don't look oval? \$\endgroup\$ Commented Feb 1, 2014 at 9:07
  • 1
    \$\begingroup\$ @LeSam I can't post an answer here because the question has been closed. I've put a quick tutorial on my blog. Oh and sorry about the downvote, your answer does work after all but recommending people use global variables in calculations every time a coordinate is set is a bad practice that leads to buggy hard to maintain code. craftworkgames.com/blog/monogame-resolution-independence \$\endgroup\$ Commented Feb 1, 2014 at 11:48
  • \$\begingroup\$ @Homer_Simpson you should ask another question \$\endgroup\$
    – LeSam
    Commented Feb 1, 2014 at 15:00

Not the answer you're looking for? Browse other questions tagged .