XImplosionX

Hello, I'm writing an RPG-Esque creation tool. And I was wondering what the best way to draw sprites would be.

1.) Draw the sprite from a Raw .gif file.

2.) Create a series of Frames for the sprite and loop through each sprite incrimenting the frame number.

I was wondering what the best approach to this is and how to impliment it.



Re: XNA Framework Drawing Animated Sprites to the Screen

Bill Reiss

The easiest is probably to create a PNG file that has all of your frames in it one after the other, then load it into a Texture2D, and then when doing the SpriteBatch.Draw() call, specify the source rectangle based on the frame you are currently drawing. You should try to avoid creating a seperate image for each, there is a lot of overhead when loading a lot of textures.

It would be even better to put all of the sprites you are drawing in the same PNG file and load them into a single texture for performance reasons. Every time you draw from a different Texture2D object there is a lot of overhea in making that switch.

Bill






Re: XNA Framework Drawing Animated Sprites to the Screen

XImplosionX

Ah, thanks. I have tried multiple Texture2D Calls before *Shudder*

I will remember that.