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

Making Them Move

You may be thinking that something's wrong with your automated sprites. You remember adding code to make them move on their own, yet they don't do anything but sit there and spin. The reason your automated sprites don't move is that you created each of the automated sprites shown in Figure 4-2 with a speed of zero: that is, in the LoadContent method of the SpriteManager class, you passed Vector2.Zero as the final parameter of the constructor for each of these objects.

To make your automated sprites move around the screen, try modifying the speed parameter you pass to those objects. Be aware that you have no logic built-in to do anything with these sprites other than move them forward, though. The result will be that your sprites will move forward and will eventually move off the screen. In coming chapters, you'll be adding some logic to dynamically create sprites and send them flying from one side of the screen to the other. This chapter and the sprite class hierarchy that you've built have laid the foundation for that future development.

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