0
\$\begingroup\$

I want that my sprite(Mario) don't look the same on every Windows Phone resolution. If I use this code, the sprite is on every resolution on the right position but it also has the same size on every resolution. In this picture, you see that the sprite on a resolution of 1280x720(it looks the same on 800x480)

Image One

Full Size

But if I don't use this code, my sprite looks smaller, but my sprite is no more on the right position if I change the resolution from 800x480 to 1280x720. Is it possible that my sprite changes it's size automatically when I change the resolution and in addition, the sprite should be drawn on the right position. In my case, the sprite should always be drawn in the center of the screen. In this picture, the sprite is smaller on a resolution of 1280x720, but the position is not correct. It should be in the center.

Image Two

Full Size

What should I change so that the sprite is always drawn on the right position when I change the resolution? I don't know how to do that.

I'm not sure what is/looks better. The first possibility(the sprite has always the same size) or the second possibility(the sprite changes it's size when I change the resolution). In addition, I want that the proportions of the sprite don't change. For example, a circle should look on every resolution like a circle. It should not look oval on a different resolution.

In my opinion, the second possibility looks better, but I'm not sure if I should do it like that. What do you think? Which possibility is better? How would you do it? What possibility is used by professional game designers?

\$\endgroup\$
  • \$\begingroup\$ Changing resolutions will just get you a bigger or smaller viewport. As long as you abstract from that using a camera, you are fine. A camera, in 2D, is usually a matrix with a orthogonal projection that defines what section of the world you are viewing. Investigate on it around your specific framework. \$\endgroup\$ – Grimshaw Feb 2 '14 at 16:12
  • \$\begingroup\$ But the sprite is not in the center in the second picture. If I have a bigger viewport, the sprite should still rest in the center. \$\endgroup\$ – Homer_Simpson Feb 2 '14 at 16:27
  • 1
    \$\begingroup\$ that usually happens when your camera equals your viewport size, in some API its considered the "default" camera active. I never used what you're using there, sorry. \$\endgroup\$ – Grimshaw Feb 3 '14 at 6:22
  • \$\begingroup\$ possible duplicate of How do I make a 2D game resolution independent? \$\endgroup\$ – user15805 Jul 23 '14 at 14:59
1
\$\begingroup\$

What are you trying to do is to implement resolution independent rendering with Camera2D features. The sprite shift is caused by the device viewport not being resized correctly when you change screen resolution so it is always begin to draw the scene from the left screen side.

If you don't like to reinvent the wheel let me advice you to look at the complete resolution independent rendering and Camera2D logic implementation for Monogame at: http://panthernet.ru/forum/index.php?/topic/17-monogamexna-examples-v18/

Examples are also included so it's very easy to start using it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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