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

Re: [pygame] spritesheets and animation



On Sunday 24 February 2008 18:09, Devon Scott-Tunkin wrote:
> Thanks, now it shows up. But it doesn't animate.  Just displays the 2nd
> frame oddly enough...

 I suspect it may be because, after the initial:

>         self.update(pygame.time.get_ticks())

 You only ever pass to the update method the number 4:

>         genesprite.update(4)

 ...which is then stored in self._last_update, and compared against the next 
value to come in... which is always 4!

 Incidentally, your Spritesheet class can probably be replaced simply by calls 
to <Surface>.subsurface(<Rect>), which has the added advantage (under most 
circumstances) in that it references the original image data, so doesn't use 
up as much memory as a copy.

 Incidentally #2, I wrote a generic animated-sprite class for pygame a while 
ago, which is more featureful than the one from piman's tutorial (which you 
appear to be using): http://raumkraut.net/libs/animsprite

 - MEl C