Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building your First Mobile Game using XNA 4.0

You're reading from   Building your First Mobile Game using XNA 4.0 A fast-paced, hands-on guide to building a 3D game for the Windows Phone 7 platform using XNA 4.0

Arrow left icon
Product type Paperback
Published in Jan 2013
Publisher Packt
ISBN-13 9781849687744
Length 158 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Thomas Goussaert Thomas Goussaert
Author Profile Icon Thomas Goussaert
Thomas Goussaert
Brecht Kets Brecht Kets
Author Profile Icon Brecht Kets
Brecht Kets
Arrow right icon
View More author details
Toc

Adding animation to our hero


The following topics will guide us on adding animation to our hero.

Sprite sheets

As cool as a sliding hero might be, it would be nice to make him walk instead of slide. We can achieve this by using sprite sheets. A sprite sheet is an image that contains multiple versions of the character in a certain state (walking for example). We then render just a part of the sprite at a time. By switching the parts we render, we can make it appear as if the character is walking. In the following screenshot, you can see the sprite sheet that we will be using. It is 256 pixels wide and contains eight different frames. Each frame is 32 pixels wide by 39 pixels high. Note that it is also possible to have multiple rows in a single sprite sheet.

The GameAnimatedSprite class

The GameAnimatedSprite class is an extension of the GameSprite class. The extra functionality it will offer is drawing sprite animations, this means calculating which DrawRect to use (a parameter we use in our...

You have been reading a chapter from
Building your First Mobile Game using XNA 4.0
Published in: Jan 2013
Publisher: Packt
ISBN-13: 9781849687744
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image