Chapter 2: Fun with Sprites
Quiz Answers
What are the steps in an XNA game loop?
The XNA game loop consists of only two methods:
Update
andDraw
.
If you wanted to load a
Texture2D
object, in which method should you do that?LoadContent
.
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);
What should you pass in as the parameter of
Content.Load
when loading aTexture2D
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.
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.
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 ...
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.