O'Reilly logo

Windows Phone 7 XNA Cookbook by Zheng Yang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Touch Directional Pad (D-pad)

In a Windows game, we have arrow keys to control directions. In Xbox, we have the gamepad controller to set different orientations. In Windows Phone 7, we only have the touchscreen for the same work, so we need another tool to accomplish this aim. The solution is the Touch Directional Pad. Touch Directional Pad gives you comfortable controlling experiences in game playing when adjusting the directions. In this recipe, you will learn how to create your own Touch Directional Pad on Windows Phone 7.

How to do it...

  1. The first step is to create a new Windows Phone 7 Game project named WindowsPhoneDpad, and change Game1.cs to DpadGame.cs. Then add field variables in the DpadGame class, as follows:
    //Font for direction ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required