Search code examples
pythonpython-2.7pygame

Clearing a group in Python


If I have a group of sprites such as:

spriteList = pygame.sprite.Group()

Is there anyway to delete all of the contents of the group?


Solution

  • Yes, simple: pygame.sprite.Group().empty() will do it.

    Edit for clarification:

    Since you have a reference to the Group object, call empty() on that reference, e.g.

    spriteList.empty()
    spriteList.add()