Sign in to follow this  

XNA Animated Sprites

This topic is 3101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know it's simple, but it's been a while since I've worked with XNA and I finally came up with this class that works with animated sprites. Here's the class (download from mediafire): Texture2DA.cs It's really simple to use too. You can either pass the constructor no arguments, and load it using the Load() function, or pass the loading arguments to the constructor. It needs a Texture2D of the sprite sheet, and two integers specifying how many rows and columns of sprites there are in the sheet. The Play() function advances the current frame by one, and the Draw() function draws the sprite and takes three arguments: the x/y coordinates (as integers), and the SpriteBatch to use. The last function, SetPlayLimit(), sets the limits of the sprite. For instance, if you only want the sprite to play the first 3 frames, you would call SetPlayLimit(1, 3) to have the sprite play from the first frame to the third frame and repeat. This entry it both to share the class and to ask for suggestions on improvement, so if you see something you think could be improved, comment here.

Share this post


Link to post
Share on other sites

This topic is 3101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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