Difference between revisions of "Hello World in XNA 3.0 using spritefont"
esse quam videri
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >") |
m (Text replacement - "</csharp>" to "</syntaxhighlight>") |
||
Line 18: | Line 18: | ||
<syntaxhighlight lang="csharp" line="1" > | <syntaxhighlight lang="csharp" line="1" > | ||
SpriteFont spriteFont; //Declare spriteFont | SpriteFont spriteFont; //Declare spriteFont | ||
− | </ | + | </syntaxhighlight> |
right below the definition of spriteBatch | right below the definition of spriteBatch | ||
<syntaxhighlight lang="csharp" line="1" > | <syntaxhighlight lang="csharp" line="1" > | ||
SpriteBatch spriteBatch; | SpriteBatch spriteBatch; | ||
− | </ | + | </syntaxhighlight> |
5. Initalize the spriteFont viriable in the Load_Content() Method right below the // TODO: use this.Content to load your game content here | 5. Initalize the spriteFont viriable in the Load_Content() Method right below the // TODO: use this.Content to load your game content here | ||
Line 31: | Line 31: | ||
// TODO: use this.Content to load your game content here | // TODO: use this.Content to load your game content here | ||
spriteFont = Content.Load<SpriteFont>("Kootenay"); | spriteFont = Content.Load<SpriteFont>("Kootenay"); | ||
− | </ | + | </syntaxhighlight> |
6. Add code to Draw some text with your new spriteFont. In the Draw() method add | 6. Add code to Draw some text with your new spriteFont. In the Draw() method add | ||
Line 40: | Line 40: | ||
spriteBatch.DrawString(spriteFont, "Hello XNA!!!", new Vector2(100, 100), Color.Silver); | spriteBatch.DrawString(spriteFont, "Hello XNA!!!", new Vector2(100, 100), Color.Silver); | ||
spriteBatch.End(); | spriteBatch.End(); | ||
− | </ | + | </syntaxhighlight> |
Revision as of 18:29, 25 January 2016
1. Create a new XNA Project
2. Right Click on the Content Folder and Choose New Item
3. Select SpriteFont. And name your file Kootenay.spritefont
4. Now we need to add some code to load our new spriteFont. Add new SpriteFont variable.
1 SpriteFont spriteFont; //Declare spriteFont
right below the definition of spriteBatch
1 SpriteBatch spriteBatch;
5. Initalize the spriteFont viriable in the Load_Content() Method right below the // TODO: use this.Content to load your game content here
1 // TODO: use this.Content to load your game content here
2 spriteFont = Content.Load<SpriteFont>("Kootenay");
6. Add code to Draw some text with your new spriteFont. In the Draw() method add
1 // TODO: Add your drawing code here
2 spriteBatch.Begin();
3 spriteBatch.DrawString(spriteFont, "Hello XNA!!!", new Vector2(100, 100), Color.Silver);
4 spriteBatch.End();