XNA Creators Club Online

beginner's guide

2D Lessons

1 Introducing the 2D Tutorial
2 Creating the Game Project
3 Adding Assets
4 Drawing the Background
5 Creating a Cannon
6 Firing Cannonballs
7 Adding Enemies
8 Destroying Enemies
9 Keeping Score
x Extra Credit - Community Tutorials

9. Keeping Score

Keep track of the player's score, increasing it on every successful UFO hit, and draw the score on the screen using a sprite-based font.

Step 1

Watch Video
Create a font definition file, and load the file in code to create a SpriteFont object.

Step 2

Watch Video
Create a new variable to track the player's score and increment it when cannonballs and enemies collide.

Step 3

Watch Video
Construct a text string with the player's current score and draw it on the screen using the SpriteFont and SpriteBatch objects.
Download source code
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG