Bagikan melalui


Automatic Rotation and Scaling (Windows Phone)

Describes automatic rotation and scaling in the XNA Framework. Rotation and scaling are done in hardware at no performance cost to the game.

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

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 nonscaled screen resolution, which can be queried by using DisplayMode or ClientBounds.

If you leave SupportedOrientations set to DisplayOrientation.Default, orientation automatically is 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.

Remarks

Ff966425.note(en-us,XNAGameStudio.41).gifWindows Phone Specific Information
Orientation settings only apply to Windows Phone-based games. There is no concept of display rotation for Windows and Xbox 360 games.