XNA Sprite Sheets
Posted: Sat May 22, 2010 3:18 pm
Can someone point me in the right direction for a simple tutorial?
Thanks,
EpicAsian
Thanks,
EpicAsian
The Next Generation of 2D Roleplaying Games
http://elysianshadows.com/phpBB3/
^This is the basic idea of it. I'll try go into a bit more detail:mattheweston wrote:You basically have one image with many sprites on it(Spritesheet). From there you have to locate within the spritesheet the individual sprite you want to draw.
First you add the spritesheet image to your project.
You then load the spritesheet into a 2D texture.
Then you can setup rectangles for the individual sprites you need.
Finally you use the rectangles that you created in your calls to the draw function.
This is at least what I've learned so far in my study of XNA.
Code: Select all
spritebatch.Draw(texture,
position,
new Rectangle(currentFrame.X * frameSize.X,
currentFrame.Y * frameSize.Y,
frameSize.X, frameSize.Y),
Color.White, 0, Vector2.Zero,
1f, SpriteEffects.None, 0);
Code: Select all
new Rectangle(currentFrame.X * frameSize.X,
currentFrame.Y * frameSize.Y,
frameSize.X, frameSize.Y),