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

Re: [pygame] spritesheets and animation



I thought that might be the problem as i was just throwing in a dummy number there to try and get it to do something, otherwise it errored out if it didn't have any number there as t was not defined.  I got it working from another example, but will try yours as well.  I didn't really understand in the equation what t was supposed to be coming from. do i just throw the get ticks in there instead of 4?

ill have to read up on subsurface, I'm completely new to all this.  I'm not worried too much right now about memory as these sprites are very small (4k), although bigger ones may become an issue.

Thanks,

Devon


Mel Collins <pygame@xxxxxxxxxxxx> wrote:
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 .subsurface(), 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


Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.