共用方式為


Game Constructor

Initializes a new instance of this class, which provides basic graphics device initialization, game logic, rendering code, and a game loop.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework.Game (in microsoft.xna.framework.game.dll)

Syntax

public Game ()

Remarks

Although the GraphicsDeviceManager constructor requires an instance of Game, if the application does not otherwise require an instance of Game it is often more desirable to implement the IGraphicsDeviceService interface to provide the same services that would be provided by the GraphicsDeviceManager.

Similarly, when creating a new ContentManager, if no instance of Game is otherwise required by the application, it is often more desirable to create a new class that implements the IServiceProvider interface rather than creating an instance of Game just to create a new instance of GraphicsDeviceManager.

Example

/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
    using (Game1 game = new Game1())
    {
        game.Run();
    }
}     
    

See Also

Reference

Game Class
Game Members
Microsoft.Xna.Framework Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP