O'Reilly logo

Learning XNA 4.0 by Aaron Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 solution. You’ll see two projects within your solution: a solution named Collision and one named CollisionContent. All resources you use in your game (images, sounds, models, etc.) should be added to your solution in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required