importing a GIF to use with XNA

Started by
0 comments, last by Bayinx 12 years, 1 month ago
I'm working on a game with a friend and he had made some good looking GIFs to use as character sprites. I've seen that others have used GIFs with XNA before so I'm sure it's possible. I'm new to both C# sharp and XNA (and the IDE) and I've found this link to a library that allows the importing of GIFs to XNA:

http://xnagif.codeplex.com/

I was hoping someone could explain how to set it up because I'm afraid that I'll ruin my game by deleting a necessary file.

Thanks in advance!
Advertisement
From what i can see its pretty straight forward. From what i see from the downloaded source code:

1. Add both projects "GifAnimation" and "GifAnimation.Pipeline" to your solution.

2. add to your game project the reference to GifAnimation and to the content project.

3. In the content projection, in your .gif image you set the content processor and inporter to the Gif animation ones.

4. In your code you just have to add the variable
GifAnimation.[color=#2b91af]GifAnimation anim;
5. in the Load content method you add
anim = Content.Load<GifAnimation.[color=#2b91af]GifAnimation>([color=#a31515]"anim1");
6. You have to update the animation in the update Method:
anim.Update(gameTime.ElapsedGameTime.Ticks);
7. Finally when you want to draw, you draw it using the method, you get the animation texture using anim.GetTexture().
spriteBatch.Draw(anim.GetTexture(), [color=blue]new [color=#2b91af]Rectangle(0, 0, 300, 300), [color=#2b91af]Color.White);

seems simple, yet i would advice you to use spritesheet based animations instead as they are more flexible, even if more trick to create from scratch.

This topic is closed to new replies.

Advertisement