AnimSprite
This is a class I wrote to allow the automatic time-based animation of pygame sprites. It is currently used to animate the propellors of Pyplanes.
The script also contains an example of AnimSprite in action: Run the file at the command-line (python animsprite.py) to start the demonstration app; a bouncing square. Various key-presses will affect the box's animation.
Features
- Only dependent on Pygame.
- Unrestricted number of named animation sequences per sprite.
- Unrestricted number of frames per animation, with arbitrary time indexes.
- Variable animation speed.
- Variable anchor point for animations which alter a sprite's size.
Download
Latest version: 1.0.4
This class is released under the MIT license (because it's short).
Usage example
import pygame.image
from animsprite import AnimSprite
bob = AnimSprite()
# Idle animation (actually just a static image)
bob.addFrame(title='idle', delay=0, surface=pygame.image.load('bob/stand.png'))
# Two-frame walking animation
bob.addFrame('walk', 500, pygame.image.load('bob/walk1.png'))
bob.addFrame('walk', 500, pygame.image.load('bob/walk2.png'))
bob.startAnim('idle')