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

Re: [pygame] Re: Remove a sprite



Teo,

There are two ways you could possibly mean that "the sprite doesn't get
removed":

1. The sprite is still in the SpriteGroup, ie still listed in
myGroup.sprites()

2. The sprite's image is still visible on the screen.

I get the feeling you're talking about 2, and people are trying to help
you out with 1.

Once you blit something to the screen, you will see it forever unless
something blits over it.

The usual loop when using RenderClear or RenderUpdates goes something like
this:

myGroup.clear() #paints the background over all the sprites in the group.
myGroup.update() #changes the positions, etc of all the sprites.
                 #all changes to sprite rect & image (including death)
                 #should happen here.
myGroup.draw() #paints the sprite images on the screen.

I think you're probably making these calls out of order.  Which would
cause similar behaviour to what you describe.

For instance, what would happen the second time through the loop if you
did this:

myGroup.clear()
myGroup.update()
myGroup.draw()
myGroup.remove( someSprite )

-sjbrown

On Thu, 5 May 2005, teo von upereth wrote:

> Thanks Matt and Andrew for your answers,
>
> I see my sprites and my board. I'm doing an abalone but your
> pygame.sprite.Group.remove(self.group, self) changed nothing. (sorry)
>
> One thing that i found very strange : when I change the x and y of a sprite. it
> looks like a duplication. I've still a sprite at the previous position and a new
> one at the new coords. Even after my b_group_sprites.draw(screen).
>
> I missed certainly something but i don't see at the moment... :o(
>
> Thanks again for your answers. :o)
>
> Teo (still learning)
>
>
>