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

Class SpriteGroup

   object --+            
            |            
AbstractGroup --+        
                |        
            Group --+    
                    |    
        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.
  add(self, sprites, level)
Add sprite to 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.
  draw(self)
draw(surface) draw all sprites onto the surface
  draw_visible(self, surface)
Draw sprites which are not marked hidden
  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.
  move(self)
  pop(self)
    Inherited from AbstractGroup
  __contains__(self, sprite)
  __iter__(self)
  __len__(self)
len(group) number of sprites in group
  __nonzero__(self)
  __repr__(self)
  add_internal(self, sprite)
  copy(self)
copy() copy a group with all the same sprites
  empty(self)
empty() remove all sprites
  has(self, *sprites)
has(sprite or group, ...) ask if group has a sprite or sprites
  has_internal(self, sprite)
  remove(self, *sprites)
remove(sprite, list, or group, ...) remove sprite from group
  remove_internal(self, sprite)
  sprites(self)
sprites() get a list of sprites in the group
  update(self, *args)
update(*args) call update for all member sprites
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Instance Variable Summary
  layer: Screen.Layer in which the sprites live.

Class Variable Summary
    Inherited from AbstractGroup
bool _spritegroup = True

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.
Overrides:
pygame.sprite.Group.__init__

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.
Overrides:
pygame.sprite.AbstractGroup.add

change_level(self, level, to_level)

Change the drawing level.

clear(self)

Clear all of the sprites in the group to the background.
Overrides:
pygame.sprite.AbstractGroup.clear

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()
Overrides:
pygame.sprite.RenderUpdates.draw

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 2.0 on Sat Dec 9 14:11:19 2006 http://epydoc.sf.net