O'Reilly logo

Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® by Robert Fonseca-Ensor, Karli Watson, Nick Lecrenski

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

CHAPTER 11 EXERCISE SOLUTIONS

Exercise 1 Solution

imageYou can achieve this kind of animation by drawing a different, but similar, image every few hundred seconds in the place of the missile. You can either have a different image to represent each frame of the missile, or you could have one big image containing many frames and use the sourceRectangle parameter of the Draw() method to cut out the appropriate frame. You might like to track each missile's age so that the missiles don't all animate in unison. Source code for this solution is available for download. The name of the file is code sample: Tank Exercise 1.

Exercise 2 Solution

image This kind of feature is best represented as a new GameComponent object. In terms of implementation, powerups are similar to missiles: They spawn randomly, and they collide with the tank. They differ in the way that they affect the tank in that they don't move and should disappear after a short time. Source code for this solution is available for download. The name of the file is code sample: Tank Exercise 2.

Exercise 3 Solution

image Having multiple screens in an XNA game is easy to achieve with GameComponent objects. You just add and remove the appropriate components ...

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