Creating Cross-Platform Games
Describes how Game Studio facilitates developing a game that will run on multiple platforms.
The XNA Framework makes developing a game with rich play on any Microsoft platform easy. Even better, once your game works on one platform, it can run on any other platform supported by the XNA Framework, using the same base source code with minimal changes.
For example, the same XNA Framework game could be built three ways: the first to be played on a desktop computer running Windows, the second to be downloaded to an Xbox 360, and a third to load onto a Zune device.
XNA Game Studio provides several features that facilitate development and management of games designed to run on multiple platforms.
The 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 will create 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, each with its own single project. If the projects in each solution reference the same source and game asset files, changes to those files will be reflected in each solution.
The drawback to this method is that each solution will have to be maintained separately. When you make changes to a project, such as adding new source and game asset files, renaming or removing items, the changes you make in one solution will not be 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 house a project folder for the following:
- Windows version of MyGame.
- Xbox 360 version of MyGame.
- Zune version of MyGame.
Each of these projects will reference the same C# code files and game asset file, but each will build a version that can execute on the intended platform.
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 very high resolution bitmaps. The Zune platform, however, has a much smaller screen and supports much 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 the Zune.
At the same time, your game may still have content assets, such as menus, that are shared across all platforms. For these assets, it will still be useful for each project to maintain a content project folder that is synchronized across all platform projects.
To accommodate this, Game Studio enables a project to contain multiple content projects. The first project, synchronized to the content folders of all other projects, can contain the shared assets. Subsequent content project folders may contain game assets specific to that platform, and can be made to be exclusive to that parent project (not synchronized to other projects).
Unsynchronized content projects are created by adding a content project, then removing its synchronized versions in other game projects. You can use the Add Game Content Project procedure to add new platform-specific content projects to code projects.
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 a game project. You are not restricted to the two described in our example. If you find it convenient to maintain more, Game Studio will permit it.