Sign in to follow this  
acddklr07

Questions on programming animated sprites

Recommended Posts

acddklr07    145
Hello, I started learning XNA today and it is going great, but I have a question. I was wondering how do you code sprites. What I mean is that if I was to get a sprite sheet from some sprite resource site how I would code it. I googled stuff for XNA pertaining to that topic or for any topic XNA tutorials and I could not find nothing on that. I already learned how to load an image and how to make it move, but I could not find any info about if it goes into this direction it will change to this picture. Particularly how the sprites is done in early Final Fantasy games, and other rpg's. ~Carl J. Loucius P.S. Sorry if it sounds kind of confusing, but I am having a hard time describing it.

Share this post


Link to post
Share on other sites
Daaark    3553
Just store which direction you are facing, and then draw the proper sprite from your array or sheet. If the user hits the right arrow key, then your direction is DIR_RIGHT (or however you choose to define it), and you use the images facing the right.
Use a timer to flip between frames.

Share this post


Link to post
Share on other sites
acddklr07    145
Hello,

Can you please expand on using a timer between frames. I do not understand that part at all. Also, how would I load it from a sheet if it has like what ever many on it. That is the thing I am wondering. Will I have to use a photo editing program and slice them up myself or is there a way I can do it?

~Carl J. Loucius

Share this post


Link to post
Share on other sites
Daaark    3553
Quote:
Original post by acddklr07
Can you please expand on using a timer between frames. I do not understand that part at all.
What is to understand? You keep track of the amount of time that has passed, and every set interval, you change which active frame you draw to the screen. If you have 2 walking right steps, and you are in the process of walking, then you want to have the 2 sprites going back and forth every x seconds.

Quote:
Also, how would I load it from a sheet if it has like what ever many on it. That is the thing I am wondering. Will I have to use a photo editing program and slice them up myself or is there a way I can do it?
You can do both. But using one sheet is more efficient. Depending on what library you are using for graphics, there are different ways to just use a certain part of the sprite sheet. You keep track of what the coordinates are for each frame, and use those.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this