Package pygame :: Module sprite :: Class Group
[show private | hide private]
[frames | no frames]

Class Group

object --+
         |
        Group

Known Subclasses:
RenderClear, EventGroup

the Group class is a container for sprites This is the base sprite group class. It does everything needed to behave as a normal group. You can easily inherit a new group class from this if you want to add more features.
Method Summary
  __init__(self, sprite)
__init__(sprite=()) instance a Group
  __len__(self)
__len__() -> int number of sprites in group
a new object with type S, a subtype of T __new__(S, ...)
  __nonzero__(self)
__nonzero__() -> bool ask if group is empty
  __repr__(self)
  add(self, sprite)
add(sprite) add sprite to group
  add_internal(self, sprite)
  copy(self)
copy() -> Group copy a group with all the same sprites
  empty(self)
empty() remove all sprites
  has(self, sprite)
has(sprite) -> bool ask if group has sprite
  remove(self, sprite)
remove(sprite) remove sprite from group
  remove_internal(self, sprite)
  sprites(self)
sprites() -> iterator return an object to loop over each sprite
  update(self, *args)
update(...) call update for all member sprites

Class Variable Summary
int _spritegroup

Method Details

__init__(self, sprite=())
(Constructor)

__init__(sprite=()) instance a Group

You can initialize a group by passing it a sprite or sequence of sprites to be contained.

__len__(self)
(Length operator)

__len__() -> int number of sprites in group

Returns the number of sprites contained in the group.

__new__(S, ...)

Returns:
a new object with type S, a subtype of T

__nonzero__(self)
(Boolean test operator)

__nonzero__() -> bool ask if group is empty

Returns true if the group has any sprites. This lets you check if the group has any sprites by using it in a logical if statement.

add(self, sprite)

add(sprite) add sprite to group

Add a sprite or sequence of sprites to a group.

copy(self)

copy() -> Group copy a group with all the same sprites

Returns a copy of the group that is the same class type, and has the same contained sprites.

empty(self)

empty() remove all sprites

Removes all the sprites from the group.

has(self, sprite)

has(sprite) -> bool ask if group has sprite

Returns true if the given sprite or sprites are contained in the group

remove(self, sprite)

remove(sprite) remove sprite from group

Remove a sprite or sequence of sprites from a group.

sprites(self)

sprites() -> iterator return an object to loop over each sprite

Returns an object that can be looped over with a 'for' loop. (For now it is always a list, but newer version of python could return different objects, like iterators.)

update(self, *args)

update(...) call update for all member sprites

calls the update method for all sprites in the group. Passes all arguments on to the Sprite update function.

Class Variable Details

_spritegroup

Type:
int
Value:
1                                                                      

Generated by Epydoc 1.1 on Sun Nov 30 19:33:13 2003 http://epydoc.sf.net