Package pygsear :: Module Drawable :: Class SpriteGroup
[show private | hide private]
[frames | no frames]

Class SpriteGroup

object --+            
         |            
     Group --+        
             |        
   RenderClear --+    
                 |    
     RenderUpdates --+
                     |
                    SpriteGroup


Specialized pygame.sprite.Group with more functionality.

The main advantage of SpriteGroup is that it knows which window its sprites live in and can draw() and clear() them without needing to pass the screen or background to the functions.
Method Summary
  __init__(self, layer, sprites)
Initialize the sprite group.
  __len__(self)
__len__() -> int number of sprites in group (inherited from Group)
a new object with type S, a subtype of T __new__(S, ...)
  __nonzero__(self)
__nonzero__() -> bool ask if group is empty (inherited from Group)
  __repr__(self)
(inherited from Group)
  add(self, sprites, level)
Add sprite to group.
  add_internal(self, sprite)
(inherited from Group)
  change_level(self, level, to_level)
Change the drawing level.
  clear(self)
Clear all of the sprites in the group to the background.
  clear_layer(self)
Not used at this time.
  copy(self)
copy() -> Group copy a group with all the same sprites (inherited from Group)
  draw(self)
draw(surface) draw all sprites onto the surface
  draw_visible(self, surface)
Draw sprites which are not marked hidden
  empty(self)
empty() remove all sprites (inherited from Group)
  has(self, sprite)
has(sprite) -> bool ask if group has sprite (inherited from Group)
  kill(self)
Call the killmethod on every sprite in this group, to remove all of the sprites from all of the groups they are in.
  move(self)
  pop(self)
  remove(self, sprite)
remove(sprite) remove sprite from group (inherited from Group)
  remove_internal(self, sprite)
(inherited from RenderClear)
  sprites(self)
sprites() -> iterator return an object to loop over each sprite (inherited from Group)
  update(self, *args)
update(...) call update for all member sprites (inherited from Group)

Instance Variable Summary
  layer - Screen.Layerin which the sprites live.

Method Details

__init__(self, layer=None, sprites=[])
(Constructor)

Initialize the sprite group.
Parameters:
layer - Screen.Layer in which the sprite lives.
sprites - Initial sprite or sequence of sprites in the group.

__new__(S, ...)

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

add(self, sprites, level=0)

Add sprite to group.
Parameters:
sprites - Either a single sprite, or a sequence of sprites.
level - Drawing layer at which to add the sprite. Higher numbers will be drawn after (on top of) lower numbers. Level can be less than 0 to indicate that sprite should be drawn below sprites at the default level.

change_level(self, level, to_level)

Change the drawing level.

clear(self)

Clear all of the sprites in the group to the background.

clear_layer(self)

Not used at this time.

draw(self)

draw(surface) draw all sprites onto the surface

Draws all the sprites onto the given surface. It returns a list of rectangles, which should be passed to pygame.display.update()

draw_visible(self, surface=None)

Draw sprites which are not marked hidden

Looks for a .hidden property on each sprite and does not draw those with hidden True

kill(self)

Call the kill method on every sprite in this group, to remove all of the sprites from all of the groups they are in.

Instance Variable Details

layer

Screen.Layer in which the sprites live. All draw() and clear() operations on the sprites will use the layer's screen and bg pygame.Surfaces.

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