Creating Cross-Platform Games

The XNA Framework makes it easy to develop a game with rich play on any Microsoft platform. Even better, once your game works on one platform, it can run on any other platform supported by the XNA Framework by using the same base source code with minimal changes. For example, the same XNA Framework game could be built for multiple platforms: to be played on a computer running Windows, to be downloaded to an Xbox 360 console, and to load onto a Windows Phone device.

XNA Game Studio provides several features that facilitate development and management of games designed to run on multiple platforms.

Structure of a Cross-Platform Game in Game Studio

When you develop a game to run on multiple platforms, there must be a separate project for each platform. Each project may reference the same source code files and game asset files, but building each project creates an executable that can run on its designated platform.

Method 1: A Solution File for Each Platform.

One approach to maintaining separate projects for each platform might be to create a solution file for each supported platform, with each having its own single project. If the projects in each solution reference the same source and game asset files, changes to those files are reflected in each solution.

A drawback to this method is that each solution must be maintained separately. When you make changes—such as adding new source and game asset files, and renaming or removing items—to a project in one solution, those same changes are not reflected automatically in other solutions.

Method 2: A Solution File with Multiple Projects

A cross-platform game is best maintained as multiple projects within a single solution so that Game Studio can more easily synchronize changes across all platforms.

For example, the Game Studio solution for MyGame might include a project folder for a:

  1. Windows version of MyGame.
  2. Xbox 360 version of MyGame.
  3. Windows Phone version of MyGame.

Each project references the same C# code files and game asset file, but each builds a version that can execute on the intended platform.

Dd282466.UsingXNA_CrossPlat_Solution(en-us,XNAGameStudio.40).png

When you use the Cross-Platform Conversion Wizards to create these parallel projects, the project created is linked to the original project.

Managing Platform-Specific Content

Source code and game asset files should be shared for all platforms as much as possible. However, some files may need to have unique versions for different platforms. This requirement occurs most frequently for game assets in the Content Pipeline. For example, to produce the highest quality images, graphic files for a game designed to run on the Xbox 360 platform may be high-resolution bitmaps. The Windows Phone platform, however, has a smaller screen and supports lower-resolution graphics. For this reason, your game projects are likely to reference differing game assets that are appropriate to each platform—large, high-resolution graphics for the Xbox 360, and small, low-resolution graphics for Windows Phone.

At the same time, your game may still have content assets, such as menus, that are shared across all platforms. For these assets, it is still useful for each project to maintain a content project folder that is synchronized across all platform projects. To accommodate this, a Game Studio solution may contain multiple content projects. One content project folder might contain the shared assets. Subsequent content project folders may contain game assets specific to a platform.

Which content project folders each platform uses is specified in its code project's Content References folder. In this example, the Content References folder for all code projects references the content project folder that contains all shared content. The Content References folders for the Xbox 360 and Windows Phone code projects each reference only the content projects that hold content specific to their platforms.

The topic How to: Create a Cross-Platform Game Solution demonstrates how this can be used to manage platform-specific content across multiple platforms.

You can create several content project folders within an XNA Game Studio solution. You are not restricted to the two described in our example. If you find it convenient to maintain more, Game Studio permits it.

Community Additions

ADD
Show: