Book Image

Windows Phone 7 XNA Cookbook

By : Zheng Yang
Book Image

Windows Phone 7 XNA Cookbook

By: Zheng Yang

Overview of this book

Developing games for Windows Phone 7, a new mobile platform, is your big chance to impact the world of mobile games. The XNA 4.0 for Windows Phone 7 integrates a lot of capabilities from software and hardware for you to create incredible games. The next generation of mobile games will be built by you. Windows Phone 7 XNA Cookbook is the best choice for you to make a game on Windows Phone 7. The book helps you to master the indispensable techniques to create your games using XNA 4.0. From the basics such as animating a 2D sprite and interacting with the customized graphical user interface to the more challenging such as 3D graphic rendering and collision detection. This comprehensive cookbook covers all the essential areas of XNA game development for Windows Phone 7, such as approaches to control the sensors, gestures and typical kinds of cameras. We also have recipes for sprite animation, texture rendering, and graphical user interface development that will give you a powerful tool to work with 2D effects. After this we move onto the more juicy stuff with recipes covering 3D graphic rendering and collision detection, and major ways to improve your loading efficiency. You will also work with Xbox live so you can take your game global. Finally, no mobile game development book would be complete without a look at performance optimization to make your games run faster. Windows Phone 7 XNA Cookbook will equip you with the firepower to rock the game world.
Table of Contents (17 chapters)
Windows Phone 7 XNA Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Deploying your game on an emulator or device


In the previous recipe, you completed your first XNA Windows Phone Game. In this recipe, you will learn more details on how you can deploy your Windows Phone application on the emulator or device.

Getting ready

When you build the Windows Phone 7 project, in the Output window, you will see the building messages similar to the following screenshot:

Here, you may be curious about Xap packaging. A .xap is a simple file similar to a .zip file, renamed to .xap. It contains the app and all relevant dependencies. There are a number of possible .xml files that could be included inside .xap, such as required security access level.

For better understanding, you could change the extension from .xap to .zip and use WinZip to extract the .zip file. Several necessary information will be presented such as the content directory with .xnbl binary files, dependency files with .dll extension, configuration xml files, an xml file named AppManifest, and so on. The xaml file is very important for Windows Phone 7 applications. This file provides the emulator or device with the application start-up information, the entry point, and the dependency.

How to do it...

After project building, the next step is to deploy your Windows Phone 7 XNA application to the device or emulator. The direct method is by using Visual Studio Deploy Options, as shown in the following screenshot:

In the drop-down list, you could choose Windows Phone 7 Emulator or Windows Phone 7 Device. If you are a member of App Hub, which is free for students and is charged at $99 for regular users, you can successfully deploy to the real device or the emulator. Otherwise, you can choose the emulator as the test platform.

If using an emulator, Visual Studio 2010 will boot the emulator first, and then initialize (this may take a long time if the user's PC does not have hardware virtualization enabled.) The next step is to copy the .xap file to the emulator and execute it.

If using the device for the first time, the preparation work is a little complex (I promise this is only once), as follows:

  1. 1. The first step is to check if the Zune software is installed on your computer. (If the Zune software has not been installed, you can download it from http://www.zune.net/en-US/products/software/download/default.htm).

    Besides this, you need to make sure that your phone has loaded the proper device drivers. At this point, you are now ready to start publishing your custom app to the phone.

  2. 2. Next, you will need to click Start | All Programs | Windows Phone Developer Tools | Windows Phone Developer Registration. You will see a screen as shown in the following screenshot. You can use the Windows Live ID that you linked to. You can also unregister the device.

    • Wow! All the preparation work is over now. It is now time for the final step, that is deploy. Open Visual Studio 2010 and choose Windows Phone 7 Device in the drop-down list.

    Note

    If you deploy the application to your phone device and not the emulator, the phone must be turned on and unlocked (displaying the start/home tiles screen). To debug on the phone you just need to hit Run (F5).

  3. 3. Run the application.

  4. 4. When you have done this, on your Windows Phone, you will need to slide over to the Application list page with a right direction button at the top-right, and search for the application you named before. Touch it and run the application.