Sunday, November 28, 2010

Windows Phone 7 Quick Tip #22 – Force Orientation in an XNA Game

While creating a Windows Phone 7 XNA game that uses the accelerometer, I noticed that as I tilted and rotated my phone, the screen orientation would switch from Landscape Left to Landscape Right, this obviously made the game a little difficult to play.

To resolve this, I simply changed the SupportedOrientations property on the graphics instance.  By default this is set to a landscape where the orientation changed based upon accelerometer input.  Adding the following line of code to my constructor resolved the issue.

graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;

-twb

No comments:

Post a Comment