[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Animation (Image Strips)
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Animation (Image Strips)
- From: "andrew baker" <failrate@xxxxxxxxx>
- Date: Sat, 20 May 2006 20:00:43 -0700
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Sat, 20 May 2006 23:00:46 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=P+t2vOZWxEq0w/H2rA1O39JF56y3DvO81xDB0vdTk/5pC3m/9OviqX79zp3AIMq1WG6nyxGwG3kpo5pdxVGN6Cwv+2tagoQczAzUK2sXZlioo19nOlkxHwqbYdws1iAaUVZ/hU6B1Hu0T2R0ioHHTUZ8vhYrJaZCeeQ7B5zS1so=
- In-reply-to: <43c.13fce48.31a12967@aol.com>
- References: <43c.13fce48.31a12967@aol.com>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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"