Your First Zune Application in XNA
Thursday, May 15 2008 - xna, zune, tutorial
Now that the dust is starting to settle around the release of the XNA 3.0 CTP, I thought it was time that some tutorials start to flow out. So I thought I would start from the beginning, In this Article I will assume that you have already downloaded Visual Studio 2008 Express or one of the other SKU's and installed the CTP.
The first thing that you need to do is fire up the Visual Studio Interface and start a new project. From there you will have a choice of starting a Windows Game or a Zune Game (There are lots of other choices for you but the two main ones are the Windows and Zune Games), for the purpose of this article I would like you to select the Windows Game.
The reason I have started with this is that we are going to first work on a windows game and them create the Zune game from the code. This will allow you to develop and debug your game on the Windows System and not have to deploy to the Zune each time you want to see it run. You will find that the Zune and Windows Game Templates are exactly the same the only difference is that the Build Options are set to compile to the Zune Platform.
Call your Application "FirstZune", once the application has started do a test build to make sure that the application compiles and runs, you should be presented with a screen like the one below.
Now that we are going to be developing the application on the windows system but want it to run on the Zune we will need to change the Graphic Device so that it will render to the same size as the Zune Display. To do this you will need to add the following code to the games main call.
Change the below section of code...
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
To look like this...
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.PreferredBackBufferWidth = 240;
graphics.PreferredBackBufferHeight = 320;
graphics.ApplyChanges();
}
The above section of code will for the Graphic Device to use a specific screen size. Now when you compile and Build the application you will be presented with a windows based XNA application that is running at the same screen size that the Zune Device can display.
Now that we have the application running on the Windows Platform we now need to create the Zune Project. To do this go to the solution explorer and right click of the "FirstZune" Project, this will bring up a context menu. As you browse down the menu you will see a Menu item "Create a Copy of Project for Zune", Select this and you will be presented with the following dialog.
As you will read from the dialog, the copy project wizard will set up the new project and link it to the current one. From this point on the changes that you make in one will be reflected in the other.
One thing that I like to do at this point is to rename the projects so that they reflect the platforms that they will run on. Doing this will only change the project names and not the Name of the compiled application, it just makes it easier to read.
To do this go to the solution explorer and right click on the Windows Project, rename it to "Windows - FirstZune". Then go to the Zune Project and rename it to "Zune - FirstZune". As you can see it makes it easier to read the projects in the solution explorer.
At this point you now have a base application that you can develop and debug in both the Windows and Zune environments.
Similar Posts
- XNA Tutorial - Base Application
- Tutorial 01 - XNA Your First Windows Game
- Phoenix, Setting up the DirectX Device

Where does that code go?