次の方法で共有


Cross-Platform Game Support in XNA Game Studio

XNA Game Studio makes it easy to develop a game on any Microsoft platform with XNA Framework support. These currently include:

  • Windows Phone
  • Xbox 360
  • Microsoft Windows

Once your game works on one XNA Framework-supported platform, it can run on any other such platform using the same base source code, with minimal changes to support specific platform features.

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.

You can create a cross-platform game using two basic methods: you can create a single solution and project for each platform, or you can create a single solution for your game with a project for each 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.

The main drawback of 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 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.41).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 Creating 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.

See Also

Developing Cross-Platform Games