Adding New Platforms to an Existing Game
If you have successfully created a game project that builds and runs on a particular platform, such as Windows Phone, Xbox 360, or Windows, you can add a new platform to your game by using XNA Game Studio's conversion facility to convert your existing game project to run on the new platform.
The conversion process creates a new game project of the desired type. The new game project is created in the same folder as the source project and shares content and settings from the original game project.
- Limitations of Game Conversion
- Cross-Platform Game Conversion
- Changes Made to a Project During Conversion
- Linked Projects After Conversion
- References the Conversion Utility Cannot Replace
- Changes that May Be Necessary After Conversion
Limitations of Game Conversion
The conversion utility is not meant to be a complete end-to-end conversion, but it greatly simplifies the process of converting a game to the corresponding platform. Some code changes are required to use features specific to the new platform. For example, if a Windows game is controlled by the keyboard and mouse, the converted game will not automatically respond to an Xbox 360 game controller. You need to add this code yourself.
You can use the cross-platform conditional compilation symbols to create sections of code that execute only for a specific platform.
Cross-Platform Game Conversion
To convert a game for another platform
Load the game into a supported version of Visual Studio tools.
On the Project menu, select the Create Copy of [project name] item (where [project name] is the name of the game project).
The presented items in the Project menu vary according to the designated platform of the currently selected project.
Windows Xbox 360 Windows Phone Create Copy of [Project Name] for Xbox 360
Create Copy of [Project Name] for Windows Phone
Create Copy of [Project Name] for Windows
Create Copy of [Project Name] for Windows Phone
Create Copy of [Project Name] for Windows
Create Copy of [Project Name] for Xbox 360
When complete, a new version of the game project is added to your solution. It is named for the platform (for example, Xbox 360 Copy of [Project Name] or Windows Copy of [Project Name]). The new game project is selected.
Press F2 if you want to rename the project from the name given by the conversion utility.
Note
The solution may only contain one copy of a project for each platform. Nonconforming solutions are unable to correctly synchronize projects and produce an error message during conversion.
Changes Made to a Project During Conversion
- All references to XNA Framework assemblies are replaced by their equivalents for the other platform.
- All original configurations are replaced by default configurations for the new platform.
- The XnaPlatform project property changes to that of the new platform.
- The Content Build Compression properties are set to the default values for the new platform.
- The ProjectGuid property is replaced. This is not the same as the GUID assembly attribute (usually found in AssemblyInfo.cs), which is not changed.
- The default Platform property and project output type settings are replaced with values for the appropriate target platform.
- Establishes the Game Profile and C# version settings for each game project according to the platform defaults.
Linked Projects After Conversion
The new project created by the conversion wizard shares code, content, and settings from the original game project through links.
Projects copied through the conversion wizard are linked so that:
- An item or folder added to any project is also added to the other projects.
- An item or folder renamed in any project is also renamed in the other projects.
- An item or folder deleted from any project is also deleted from the other projects.
All other actions not specifically cited above are not synchronized between projects. Of particular note, this includes the following actions:
Excluding an item from a project has no effect on other projects. This is useful for items that are inappropriate for one or more platforms, yet needed for another platform (or platforms). For an example, see Creating a Cross-Platform Game Solution.
Changing properties in a project or folder has no effect on other projects.
Adding or deleting references to content projects in the Content References folder has no effect on other projects.
Tip
Folders that are empty (as when they are first created) are not synchronized between projects. Once items are placed in a folder (so that it is no longer empty), the folder is synchronized across all other projects.
References the Conversion Utility Cannot Replace
HintPath metadata (added using browse-to-file) and strong name references are changed into simple-named references.
Project references to non-XNA Framework projects are deleted.
Note
Unlike references to non-XNA Framework projects, all referenced XNA Framework game or game library projects are recursively converted. This means that if an XNA Framework project references another in the solution (with a project-to-project reference), conversion of the referencing project automatically converts the referenced project. The result is the converted copy of the first project referencing the converted copy of the second project. For example, if you are converting a Windows game to the Xbox 360 that references a Windows game library in the same solution, conversion also occurs for the Windows game library. After a completed conversion, the result is an Xbox 360 game (a converted copy of the Windows game) that references an Xbox 360 game library (a converted copy of the Windows game library).
COM references are deleted. The conversion wizard sends a warning to the output window when this occurs.
COM file references are deleted. The conversion wizard sends a warning to the output window when this occurs.
Web references are removed, possibly resulting in compile time errors for the converted project. For example, any code that instantiates a web reference-related class or invokes its methods causes compile-time errors. The conversion wizard sends a warning to the output window when this occurs.
Warning
If you need to remove a file from only one project, use the Exclude from Project command rather than the Delete command. The Delete command removes the file from disk, making it inaccessible to the other project.
Changes that May Be Necessary After Conversion
In some cases, a converted reference (for example, a strong name reference) may fail to resolve. If this happens, either delete the reference or replace it with a reference to an assembly version for the correct platform. For example, if a reference to System.Data (often added automatically to Windows projects) was converted for Xbox 360, you must remove it becauseXbox 360 does not support System.Data. However, if the converted reference was to something like a third-party game engine, you might be able to change the reference to an Xbox 360 version of the engine instead.
If a converted reference is deleted, ensure that any platform-specific code does not depend on that reference.
Any code specific to one target platform—for example, mouse-based user input in a Windows game—will not be converted for the other platform. You must manually change this code to use an Xbox 360-compatible input device.
Other common examples include any settings files (due to missing types), code generated from any Windows Forms in the project, and certain types of resources. For example, string or binary resources are fine, but bitmap resources fail.
Usage of APIs that may be incompatible with the Game Profile capabilities of the new platform. For example, a Windows game that calls graphics APIs that function for the HiDef profile will not work after being converted for the platform, which only supports the Reach profile. In this case, further conversion of the code design is needed to use APIs compatible with the lower-capability Reach profile.
References to content projects in the Content References folder of the project, if they contain content that is incompatible with the project's platform. For example, an Xbox 360 project may reference content that is too complex for use on Windows Phone. You may wish to create a new content project that contains lower-resolution versions of the same assets for Windows Phone. After copying the Xbox 360 project to a Windows Phone project, change the items in the Content References so that the project uses the content project containing the lower-resolution assets.
See Also
Developing Cross-Platform Games
Creating a Windows Game or Library Project
Creating an Xbox 360 Game or Library Project
Creating a Windows Phone Game or Library Project