Table of Contents

How to manage automatic rotation and scaling

A walkthrough what is involved in figuring out if two objects collide for MonoGame!

Overview

This topic describes automatic rotation and scaling in the MonoGame Framework. Rotation and scaling are done in hardware at no performance cost to the game.

Setting the Preferred Device Orientations

If your game supports more than one display orientation, as specified by SupportedOrientations and described with DisplayOrientation, the MonoGame Framework automatically rotates and scales the game when the OrientationChanged event is raised.

When the device's orientation is changed

The current back buffer resolution is scaled, and can be queried by using PreferredBackBufferWidth and PreferredBackBufferHeight. These values will not be the same as the non-scaled screen resolution, which can be queried by using DisplayMode or ClientBounds.

Orientation defaults

If you leave SupportedOrientations set to DisplayOrientation.Default, orientation is automatically determined from your PreferredBackBufferWidth and PreferredBackBufferHeight. If the PreferredBackBufferWidth is greater than the PreferredBackBufferHeight, the game will run in the landscape orientation and automatically switch between LandscapeLeft and LandscapeRight depending on the position which the user holds the phone. To run a game in the portrait orientation, set the PreferredBackBufferWidth to a value smaller than the PreferredBackBufferHeight.

See Also

Concepts

Reference

© 2012 Microsoft Corporation. All rights reserved.