DylanAHolcomb
DylanAHolcomb

Reputation: 1

How do I make my XNA game fullscreen while maintaining aspect ratio and centered?

I haven't been able to find any good tutorials for making a game fullscreen while maintaining the aspect ratio. It's a bit difficult for me to describe in words, so I'll show you in two pictures.

What I currently have:
https://dl.dropbox.com/u/51911679/Pictures/Whocares/Screenshots/whatIgot.jpg

What I want:
https://dl.dropbox.com/u/51911679/Pictures/Whocares/Screenshots/whatIwant.jpg

Upvotes: 0

Views: 5033

Answers (1)

user155407
user155407

Reputation:

The GraphicsDeviceManager class can handle most of this for you:

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        graphics.IsFullScreen = true;
        graphics.PreferredBackBufferWidth = 1280;
        graphics.PreferredBackBufferHeight = 720;

        //...
    }

Now, you have to make sure you're actually drawing the whole screen in your SpriteBatch coordinates (base them on your width & height).

Upvotes: 2

Related Questions