Adding a Sprite to Your Project
All right, I said no more talk, and this time I'm serious. Let's get to it. Your project thus far has been fairly boring. Now, let's draw an image on the screen in your game.
All graphics, sounds, effects, and other items are loaded in XNA through something called the content pipeline. Essentially, the content pipeline takes things such as .jpg files, .bmp files, .png files, and other formats and converts them during compilation to an internal format that's friendly to XNA. It also does similar things with other types of resources, such as sound files, 3D models, fonts, etc., which will be explored later in this book. A great benefit of the XNA Framework is that it takes a lot of the guesswork out of importing different file types. If you put an image file into your game and the content pipeline is able to recognize it during compilation, you don't have to worry about the format of the image. (We'll talk more about the content pipeline in later chapters.)
Download the source code for this chapter and place it somewhere on your PC's hard drive. You'll need to do this so that you can access the images that you'll be adding to your project throughout the rest of this chapter.
Open Visual Studio's Solution Explorer and take a look at your project. You'll see a Content node, through which all resources (images, sounds, models, etc.) will be added to your project. Because I'm an organization-junkie, I recommend creating a subfolder within the Content node ...
Get Learning XNA 3.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.