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.
1. The first step is to create a new Windows Phone 7 Game project named
WindowsPhoneDpad
, and changeGame1.cs
toDpadGame.cs
. Then add field variables in theDpadGame
class, as follows://Font for direction status display SpriteFont font; //Texture Image for Thumbstick Texture2D texDpad; //4 direction rectangles Rectangle recUp; Rectangle recDown; Rectangle recLeft; Rectangle recRight; //Bounding Rectangle for the 4 direction rectangles Rectangle...