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

Re: [pygame] Changing the size of a sprite



I'm trying to change the size and position of a sprite in its "update"
method - the position changes fine, but the size stays the same.
Here's the code:

    def update(self):
        mapx,mapy,mapsize = self.map.PositionAnimal(self.x,self.y)
        self.rect.topleft = mapx, mapy
        self.rect.width = mapsize
        self.rect.height = mapsize
        print "updated:", self.rect.width

The PositionAnimal function returns the new position and size of the
sprite, and the debug print at the end reflects the new size.  The
sprite moves when PositionAnimal tells it to, but stays the same size.

Am I missing something here?  Have I provided enough information?

You may want to look in the python code repository (PCR). There
is a "Zoomable Surface" entry there:

http://www.pygame.org/pcr/zoom_surface/index.php


Or in pygsear, there is the Util.scale_image() function.
(http://www.nongnu.org/pygsear/)

I should probably add a sprite method that calls that...

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail