XNA Basics (01) Game Cycle

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.