Skip to Main Content
Learning XNA 3.0
book

Learning XNA 3.0

by Aaron Reed
November 2008
Beginner content levelBeginner
510 pages
16h 24m
English
O'Reilly Media, Inc.
Content preview from Learning XNA 3.0

Chapter 2: Fun with Sprites

Quiz Answers

  1. What are the steps in an XNA game loop?

    • The XNA game loop consists of only two methods: Update and Draw.

  2. If you wanted to load a Texture2D object, in which method should you do that?

    • LoadContent.

  3. What line of code should you use to change the framerate of an XNA game to 20 fps?

    • Either of these lines will do the trick:

      TargetElapsedTime = TimeSpan.FromMilliseconds(50);
      TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 50);
  4. What should you pass in as the parameter of Content.Load when loading a Texture2D object?

    • The asset name of the texture image you want to load. You can find an image's asset name by viewing its properties in Solution Explorer.

  5. Fact or fiction: the content pipeline will let you know at compile time if you add an image to your project that it cannot parse.

    • Fact. The content pipeline runs a compilation step on all content (textures, models, sounds, etc.) and then outputs the result as an XNA-compatible formatted object. If this step fails during compilation, the result is a compilation error.

  6. You're drawing a sprite, and you want the background to be transparent. What steps do you need to take to draw it with a transparent background?

    • There are two ways to draw transparent images in XNA. The first option has two requirements. First, the background of your image itself must be transparent. If it isn't, you'll need to edit the image in an image editor and give it a transparent background. Second, SpriteBlendMode.AlphaBlend must be used (this is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XNA 4.0

Learning XNA 4.0

Aaron Reed
Beginning C# 7 Programming with Visual Studio 2017

Beginning C# 7 Programming with Visual Studio 2017

Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid

Publisher Resources

ISBN: 9780596154905Supplemental ContentErrata Page