Can someone point me in the right direction for a simple tutorial?
Thanks,
EpicAsian
XNA Sprite Sheets
Moderator: Coders of Rage
- davidthefat
- Chaos Rift Maniac
- Posts: 529
- Joined: Mon Nov 10, 2008 3:51 pm
- Current Project: Fully Autonomous Robot
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: California
- Contact:
Re: XNA Sprite Sheets
http://creators.xna.com/en-US/sample/spritesheet
There are tons of tutorials on this site, which is owned and operated by microsoft, its their main XNA site
There are tons of tutorials on this site, which is owned and operated by microsoft, its their main XNA site
- epicasian
- Chaos Rift Junior
- Posts: 232
- Joined: Mon Feb 22, 2010 10:32 pm
- Current Project: Gigazilla Engine
- Favorite Gaming Platforms: Dreamcast, SNES, PS2, PC
- Programming Language of Choice: C/++
- Location: WoFo, KY
Re: XNA Sprite Sheets
I've looked at that, I guess I was to aggravated to actually sit down and look at all the code.
Thanks,
EpicAsian
Edit:
So, in XNA, The sprite sheets are just a lot of different, single image files?
I'm used to loading in one file with many sprites on it (SDL).
~EpicAsian
Thanks,
EpicAsian
Edit:
So, in XNA, The sprite sheets are just a lot of different, single image files?
I'm used to loading in one file with many sprites on it (SDL).
~EpicAsian
-
- Chaos Rift Junior
- Posts: 200
- Joined: Mon Feb 22, 2010 12:32 am
- Current Project: Breakout clone, Unnamed 2D RPG
- Favorite Gaming Platforms: PC, XBOX360
- Programming Language of Choice: C#
- Location: San Antonio,Texas
- Contact:
Re: XNA Sprite Sheets
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.
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.
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: XNA Sprite Sheets
^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),
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup