Saturday, December 25, 2010

XNA Game Development Tips and Tricks 1: Windows Phone 7 Portrait Mode

Hello, with this blog post I am starting tips and tricks on Developing Games on Windows Phone 7 using XNA.. or in general XNA.

By default whenever you develop game for Windows Phone 7 using XNA, your game will always start in Landscape mode. Your emulator will start in portrait mode, but game is playable in landscape mode.

image

Let’s say you have requirement of developing game for portrait mode and not landscape mode, you have to add 2 lines of code. In your game after you initialize GraphicsDeviceManager write following 2 lines:

 

public Game1()
{
    graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";
    graphics.PreferredBackBufferWidth = 480;
    graphics.PreferredBackBufferHeight = 800;

    TargetElapsedTime = TimeSpan.FromTicks(333333);
}

 

after writing above code, compile and run it. .and you will have your game starting in Portrait mode.

image

No comments:

Post a Comment