MULTIMEDIA

Microsoft XNA Game Studio 3.0 : Writing Your First Program (part 2) - Running the Same XNA Game on Different Devices

1/22/2011 4:34:10 PM

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.


Figure 4. Stopping a running program


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.

Figure 5. Copying a project


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.

Figure 6. Multiple projects


Figure 7. Selecting the StartUp Project


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."

Figure 8. Selecting a deployment target


You can change this option at any time, depending on which platform you are working with.

Other  
  •  Programming with DirectX : Shading and Surfaces - Additional Texturing Topics
  •  iPhone 3D Programming : Adding Textures to ModelViewer (part 4) - Enabling Textures with ES2::RenderingEngine
  •  iPhone 3D Programming : Adding Textures to ModelViewer (part 3) - Enabling Textures with ES1::RenderingEngine
  •  iPhone 3D Programming : Adding Textures to ModelViewer (part 2) - Generating Texture Coordinates
  •  iPhone 3D Programming : Adding Textures to ModelViewer (part 1) - Enhancing IResourceManager
  •  Programming with DirectX : Shading and Surfaces - Implementing Texture Mapping (part 2) - Multi Texture Demo
  •  Programming with DirectX : Shading and Surfaces - Implementing Texture Mapping (part 1) - 2D Texture Mapping Demo
  •  Building Out Of Browser Silverlight Applications - Using COM Interoperability and File System Access
  •  Building Out Of Browser Silverlight Applications - Controlling the Application Window
  •  iPhone 3D Programming : Adding Depth and Realism - Loading Geometry from OBJ Files
  •  iPhone 3D Programming : Adding Depth and Realism - Better Wireframes Using Polygon Offset
  •  Programming with DirectX : Textures in Direct3D 10 (part 2)
  •  Programming with DirectX : Textures in Direct3D 10 (part 1) - Textures Coordinates
  •  Programming with DirectX : Shading and Surfaces - Types of Textures
  •  iPhone 3D Programming : Adding Shaders to ModelViewer (part 2)
  •  iPhone 3D Programming : Adding Shaders to ModelViewer (part 1) - New Rendering Engine
  •  iPhone 3D Programming : Adding Depth and Realism - Shaders Demystified
  •  Programming with DirectX : Transformation Demo
  •  Programming with DirectX : View Transformations
  •  Programming with DirectX : World Transformations
  •  
    Most View
    The Connected BlackBerry : Roaming Across Networks, Service Routing, Coverage Info API, Connection Security
    Most Favorite Creativity Apps For Your Smartphone – November 2012
    DSLR – Your Video’s Best Friend (Part 2)
    Windows Vista : Deploying Applications - Automating Installation, Repackaging Legacy Applications
    How To Import Images
    Nikon Coolpix A – An Appealing Camera For Sharp Images (Part 2)
    Panasonic Lumix GF6 Latest Mirrorless Camera Review (Part 2)
    Tech Spelunk - Google Nexus 7
    Sony NSZ-GS7 - Internet Player With Google TV
    The Best PC Deals Around – May 2013 (Part 2)
    Top 10
    HTC One - Great For Music-Lovers (Part 3)
    HTC One - Great For Music-Lovers (Part 2)
    HTC One - Great For Music-Lovers (Part 1)
    Huawei Ascend P1 Android Smartphone
    Essential Extra - Got An Android Phone Or Tablet? (Part 2)
    Essential Extra - Got An Android Phone Or Tablet? (Part 1)
    For Start-Ups, The Cloud Is The Way To Go!
    Hauppauge HD PVR 2 Gaming Edition
    Hot Technologies From A Cloud Country (Part 2)
    Hot Technologies From A Cloud Country (Part 1)