3
\$\begingroup\$

How can I load a GIF animation in pygame? With a web search, I found a severely outdated library called GIFImage. I tried it to do it with 2 pictures but I'm getting stuck because I'm a beginner. I also found something about making animations with Sprites, but no tutorial...

How do I do this?

Anko
13.5k10 gold badges56 silver badges82 bronze badges
asked Apr 30, 2014 at 21:26
\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

I think what you mean is, how to load an animated GIF in pygame.

It's true that pygame doesn't support animated GIFs natively, and you'd need GIFImage for that. Not sure how well it works, but I wouldn't recommend it anyway.

This is because in games you usually want to control the animation yourself. Use a spritesheet or separate images for your sprite frames. Then swap out the image in your game. See this question for more details.

For the record, if the GIF isn't animated, it's trivial:

sprite_image = pygame.image.load("image.gif").convert_alpha()
answered Apr 30, 2014 at 23:56
\$\endgroup\$
1
  • \$\begingroup\$ So if some one was interested in using an animated gif in Pygame, not worrying about sprite animations or controlling the animation, where would one find this GIFImage you speak of? It appears the links on pygame.org are all broken. I am using Pygame to load and display images on a screen, no real user interaction required, and would like to include some animated gifs into this, thanks! \$\endgroup\$ Commented Jun 26, 2014 at 13:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.