[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Animation (Image Strips)




One quick and easy way is to make a strip of alpha color.  Then, split it up by the width of each frame.  For example, if I have 4 images in an animation loop, each 64 x 64, I'd need a strip 64 pixels high and 256 pixels wide.  Then, draw a fram of animation in each cel.
When you load in the strip file, you can either slice it up now (I'd suggest Numeric) and put each slice into a list, or you can use a viewport technique later.  I'd suggest slicing it now, as I believe it's cheaper on processing in the long run.  Now, you can on the sprite's update set self.image = strip[i], where i is the current index.  It's recommended to put a delay of a few cycles between each increment.

Ta,

--
Andrew Ulysses Baker
"failrate"