XNA Tutorial 1: Hello world

Start XNA Game studio and create a new Windows game project.

Right click Content folder and choose Add, New Item.
Select Sprite Font and rename it to some font you like, such as “Arial”.

You can now open the file and modify some of the options such as Size or Style.

Locate the following code:

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.CornflowerBlue);
 
    // TODO: Add your drawing code here
 
    base.Draw(gameTime);
}

[ad]

And finally add the code to draw a string:

spriteBatch.Begin();
 
spriteBatch.DrawString(Content.Load<SpriteFont>("Arial"), "Hello world", new Vector2(100, 100), Color.Black);
 
spriteBatch.End();

[ad]

Easy, isn’t it?

3 thoughts on “XNA Tutorial 1: Hello world

  1. ElvenProgrammer Post author

    Background should be white or gray, can you show a screenshot of what you see?

Leave a Reply

Your email address will not be published. Required fields are marked *