In pygame, groups have a lostsprites
attribute. What is this for?
Link to where its first defined in the code: pygame/src_py/sprite.py
It seems to be some sort of internal thing as I was unable to find any documentation on its purpose:
lostsprites
is an internal attribute that helps to keep track of all rectangular areas affected by the operations of the group. The attribute is implemented in the base class AbstractGroup
and the exact behavior depends on the type of the group (Group
, RenderUpdates
, OrderedUpdates
, ...).
The draw
method returns all the areas that were changed during drawing. This includes not only the areas that the sprites were before and the new areas of the sprites, but also the areas of the removed sprites (e.g. pygame.sprite.kill
). This is where lostsprites
comes into play. When a sprite is removed from the group, the rectangular area where the sprite was is added to lostsprites
and later this information is used in draw
.