When the VS 2008 and XNA Gamestudio 3.0 are installed, we can begin to learn the XNA.
First, creating a new XNA Gamestudio 3.0 project in VS 2008 (Choosing a Windows game type) generates one of the simplest, running game templates.
Next we turn our attention to the focus we are trying to dissect--the Game1 class inherited from Microsoft.Xna.Framework.Game, whose code is as follows:
public class Game1:Microsoft.Xna.Framework.Game
{
Graphicsdevicemanager graphics;
SpriteBatch SpriteBatch;
Public Game1 ()
{
Graphics = new Graphicsdevicemanager (this);
Content.rootdirectory = "Content";
}
protected override void Initialize ()
{
Base. Initialize ();
}
protected override void Loadcontent ()
{
SpriteBatch = new Spri Tebatch (GraphicsDevice);
}
protected override void Unloadcontent ()
{
}
Prote cted override void Update (Gametime gametime)
{
if (gamepad.getstate). Buttons.back = = buttonstate.pressed)
this. Exit ();
Base. Update (gametime);
}
protected override void Draw (Gametime gametIME)
{
Graphicsdevice.clear (color.cornflowerblue);
Base. Draw (gametime);
}
}
Let's briefly explain the important types that are used in this class.
Graphicsdevicemanager Graphics Device Manager for access to the graphics device's channel.
GraphicsDevice graphics devices.
The Sprite Wizard, drawing a 2D or 3D image on the screen, such as a monster in the game scene is a Sprite.
SpriteBatch it uses the same method to render a set of Sprite objects.