3. Stopping a Program
Before you do
anything else, you need to stop the program. There are two ways to do
this. You can press the Back button on an Xbox 360 gamepad or Zune to
instruct the program to finish. If the program is running on a remote
device, XNA Game Studio displays a message indicating that the remote
connection to the device has been lost. Simply click OK on the message
to dismiss it. Alternatively, you can stop the program from within XNA
Game Studio by clicking the Stop button indicated by the arrow in Figure 4.
If you are using a PC and don’t have an Xbox gamepad, you have to stop the program from XNA Game Studio.
Note:
You should not normally
stop your program by using XNA Game Studio. This is like turning off
your Xbox 360 rather than quitting a game correctly. It stops the
program, but because the program is interrupted, it might not save all
the game data properly before it stops. When you make your own game, you
should make sure that you provide the player with instructions on how
to stop it properly.
![](http://programming4.us/image/012011/Writing%20Your%20First%20Program_4.jpg)
4. Storing Games on the Xbox 360 or Zune
Once
you’ve created a game and deployed it to an Xbox 360 or Zune, the game
itself remains stored inside the machine for you to load and play later,
without the need for a PC to be attached. You can find the games you
have created by selecting your Game Library on the Xbox 360 or entering
the Games menu on the Zune.
5. Running the Same XNA Game on Different Devices
You can use a single
XNA workspace to hold multiple projects, one for each device you want to
target. The following example shows how a Windows PC project can be copied to produce an Xbox 360 project.
5.1. Creating a Copy of an XNA Project for Another Device
Start
by clicking the MoodLight project in the Solution Explorer of XNA Game
Studio so that it is selected. Then choose Create Copy Of MoodLight For
Xbox 360 from the Project menu, as shown in Figure 5.
![](http://programming4.us/image/012011/Writing%20Your%20First%20Program_5.jpg)
XNA Game Studio now
copies the project and adds the copy to the workspace. This means that
there are now two projects in the workspace, as shown in Figure 1-8.
Note:
It looks as if there
are now two copies of everything concerned with the project. This is not
actually the case. The copy uses links to the files in the original.
This means that changes to the content of one project are reflected in
the other.
You can select which of the projects started by setting one of the projects as the StartUp Project. If you look carefully at Figure 6,
you see that the Windows version of MoodLight has the name of the
project displayed in bold type. This means that it is the project that
runs on the Windows machine. To set a project as the StartUp project,
you right-click the project and choose Set As StartUp Project from the
menu that appears, as shown in Figure 7.
![](http://programming4.us/image/012011/Writing%20Your%20First%20Program_6.jpg)
![](http://programming4.us/image/012011/Writing%20Your%20First%20Program_7.jpg)
When you click Start Debugging, the project that is selected as the StartUp project is the one that gets to run.
5.2. Selecting Your Deployment Targets
If your
solution contains multiple projects that target different devices, XNA
Game Studio attempts to send a compiled program to each of them when you
try to run the program. This can be a problem, if for example you want
to work on the Windows PC version of your program and don’t have your
Xbox 360 switched on. You can select where the compiled programs are
sent by using the combobox at the top of XNA Game Studio, as shown in Figure 8.
If you set this to Mixed Platforms, the program is sent to every
device. Otherwise, pick just the target that you want. To deploy the
game just to your Windows PC (both 32-bit and 64-bit versions), you need
to set it to "x86."
![](http://programming4.us/image/012011/Writing%20Your%20First%20Program_8.jpg)
You can change this option at any time, depending on which platform you are working with.