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

Re: [pygame] Could sprite drawing be done but a Sprite.draw function?



On Mon, Jul 25, 2011 at 4:53 PM, DR0ID <dr0id@xxxxxxxxxx> wrote:
On 25.07.2011 11:13, Mac Ryan wrote:
Hi and thank you for your answer.

       I think I failed to explain myself properly. What I meant with
my question is that I have been surprised that the drawing of sprites
happens **calling surface.blit(sprite.image, sprite.rect)** instead than
**calling sprite.draw()**. It makes of course sense that drawing is
co-ordinated by the group, but the way it's done now make very hard to
"customise" the drawing: I might need for example to selectively choose
a flag for the blit operation on_some_  of the sprites, for example...

       Hope this clarify what's my doubt better!:)

       Mac

Hi

You could use a DirtySprite (this sprite has attributes for all the blit arguments) with the corresponding group(s):

http://www.pygame.org/docs/ref/sprite.html#pygame.sprite.DirtySprite


~DR0ID


Indeed.  Using the DirtySprite and LayeredDirty group might be good.

Also, you can do things in the update method, which gets called before things are drawn.  This means you can make the sprite not be drawn by setting its rect to be zero sized, or make modifications to the Surface (eg, tint it red in if the sprite is bleeding).


cheers,