Chapter 3. Orientation

WHAT'S IN THIS CHAPTER?

  • Understanding and using the accelerometer

  • Determining what orientation strategies to use for your game

  • Running your game in full-screen mode

All Windows Phone 7 devices contain an integrated accelerometer and compass that you can use to determine the device's direction and orientation.

The ability to play games on the phone without having to touch the screen creates numerous possibilities for interaction. Imagine how intuitive your game would be if you could steer a car or fly a jet by holding your phone like a steering wheel or yoke.

DEVICE ORIENTATION

When creating games, you must decide early in the process how you want to display your screens. The phone has two possible orientations: Portrait and Landscape. In the simplest possible terms, Portrait is the vertical orientation, and Landscape is horizontal.

A traditional arcade experience such as a building climber or a Space Invaders type of game would be best presented in Portrait mode. On the other hand, if your game requires a more tactical viewpoint, perhaps Landscape mode makes more sense.

Setting Device Orientation

By default, all games on Windows Phone 7 run in Landscape mode, meaning a backbuffer width of 800 pixels and a height of 480 pixels. To make your game run in Portrait mode, you must set the backbuffer width and height to 480 and 800 pixels, respectively.

Hardware Scaling

The phone includes a hardware image scaler, which means that your games can render to any size of backbuffer, ...

Get Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.