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?
1 Answer 1
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()
-
\$\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\$sec_goat– sec_goat2014年06月26日 13:16:50 +00:00Commented Jun 26, 2014 at 13:16