Aracılığıyla paylaş


Creating a Visual Basic Windows Phone Game or Library Project

Describes how to use VB XNA Game Studio to create an XNA Framework application.

Starting a New Visual Basic Project

To start a new Visual Basic project

  1. To begin a new Visual Basic project, click File, and then click New Project.

    If you installed Visual Studio with settings other than Visual Basic Development Settings, you can find the Visual Basic node beneath Other Languages in the template hierarchy.

    You are presented with a dialog box that lists a number of project templates.

Hh477144.XNAVB_Projects(en-us,XNAGameStudio.41).png

XNA Game Studio provides template types for XNA Framework game development in the XNA Game Studio 4.0 Refresh section of the Visual Basic project types. The templates offered for developing XNA Framework games for Windows Phone are:

Project type Description
Windows Phone Game (4.0) A project for creating an XNA Framework 4.0 game application for Windows Phone.
Windows Phone Game Library (4.0) A project for creating an XNA Framework 4.0 game library for Windows Phone.
Content Pipeline Extension Library (4.0) A project for creating an XNA Framework 4.0 Content Pipeline Extension Library.

Windows Phone Game (4.0)

XNA Game Studio provides a Windows Phone Game (4.0) template that creates and loads a set of starter files. This new project contains basic code that renders a colored (cornflower blue) background.

To create a Windows Phone Game (4.0) project

  1. On the File menu, click New Project.

  2. Select the Windows Phone Game (4.0) project type.

  3. Type the name for the game project in the Name text box.

    You can also modify the default values for the Location and Solution Name controls.

  4. Click OK to create and load the new project.

Results

After creating a new Windows Phone game, your solution in Visual Studio 2010 should look like the following image.

XNA Visual Basic Game Project

The new starter project contains the following important features.

  • Project Properties
    The properties defined in My Project control many aspects of your current project. Some examples include general application settings, debug settings, and additional project resources. Double-clicking the My Project item opens the Project Designer, where you can modify the values for these properties.

  • References
    References to the following assemblies are added automatically to a new Windows Phone Game project:

    • Microsoft.Xna.Framework
    • Microsoft.Xna.Framework.Game
    • Microsoft.Xna.Framework.GamerServices
    • Microsoft.Xna.Framework.Graphics
    • Microsoft.Xna.Framework.Input.Touch
    • mscorlib
    • System
    • System.Core
    • System.Net
    • System.Xml
    • System.Xml.Linq

    The references can be viewed on the References Page of the Project Designer for Visual Basic. In addition to these standard assemblies, you can add other assemblies as needed for your project.

  • Content References
    The Content References folder is initially empty. If you add a Content Project to the solution to hold content assets, you should add a reference to the Content Project in the Content References folder. This is useful for including reusable content assets that support the classes and methods in the game library. For more information, see Game Content Project.

  • Background.png File
    A 62 x 62 tile image that represents your game. This image is displayed when the game is pinned to the Start screen on the Windows Phone.

  • Game1.ico File
    A 32 x 32 default icon representing your game. This icon is not used by the Windows Phone project, but is furnished in case the project is copied to an Xbox 360 or a Windows project where it is required.

  • Game1.vb File
    This file is a good starting point for adding simple game logic and basic features. It implements a single class (derived from Game and called Game1), and overrides five methods: LoadContent, UnloadContent, Initialize, Draw, and Update. Use these methods to initialize your game components, to load and render your game content, and to handle any input from the user or changes to the game environment. In addition, the Game1 constructor is defined.

  • PhoneGameThumb.png File
    A 173 x 173 default icon representing your game. This icon is shown when the game is displayed in the Games Hub of the Windows Phone device.

  • Program.vb File
    This file implements a single class (called Program) that provides an entry point to game execution. Usually, little code is added to this file unless the game is fairly advanced.

Windows Phone Game Library (4.0)

XNA Game Studio provides a Windows Phone Game Library (4.0) template that creates and loads a set of starter files. Typically, projects of this type contain managed classes that implement basic or advanced features used by a game engine. Once completed, these class libraries can be referenced by other Windows Phone projects. Also, they provide common functionality without having that code reside within the game project.

The new project contains basic code that implements an empty library, usable by other Windows Phone Game projects or Windows Phone Game libraries.

To create a Windows Phone Game Library (4.0) project

  1. On the File menu, click New Project.

  2. Select the Windows Phone Game Library (4.0) project type.

  3. Type the name for the library project in the Name text box.

    You can also modify the default values for the Location and Solution Name controls.

  4. Click OK to create and load the new project.

Results

After creating a new Windows Phone game library, your solution in Visual Studio 2010 should look like this:

XNA Visual Basic Game Library Project

The new starter project contains the following important features.

  • Project Properties
    The properties defined in My Project control many aspects of your current project. Some examples include general application settings, debug settings, and additional project resources. Double-clicking the My Project item opens the Project Designer, where you can modify the values for these properties.

  • References
    References to the following assemblies are added automatically to a new Windows Phone Game Library project:

    • Microsoft.Xna.Framework
    • Microsoft.Xna.Framework.Game
    • Microsoft.Xna.Framework.GamerServices
    • Microsoft.Xna.Framework.Graphics
    • Microsoft.Xna.Framework.Input.Touch
    • mscorlib
    • System
    • System.Core
    • System.Net
    • System.Xml
    • System.Xml.Linq

    In addition to these standard assemblies, you can add other assemblies as needed for your project.

  • Content References
    The Content References folder is initially empty. If you add a Content Project to the solution to hold content assets, you should add a reference to the Content Project in the Content References folder. This is useful for including reusable content assets that support the classes and methods in the game library. For more information, see Game Content Project.

  • Class1.vb File
    This file implements an empty Visual Basic class within a namespace. It provides a starting point for the class library.

See Also

Getting Started with XNA Game Studio Development
Sharing Your Game Package