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

Class Sprite

object --+
         |
        Sprite

Known Subclasses:
Drawable, Event

the base class for your visible game objects. The sprite class is meant to be used as a base class for the objects in your game. It just provides functions to maintain itself in different groups. A sprite is considered 'alive' as long as it is a member of one or more groups. The kill() method simply removes this sprite from all groups.
Method Summary
  __init__(self, group)
__init__(group=()) initialize a sprite object
a new object with type S, a subtype of T __new__(S, ...)
  __repr__(self)
  add(self, group)
add(group) add a sprite to container
  add_internal(self, group)
  alive(self)
alive() -> bool ask the life of a sprite
  groups(self)
groups() -> list list used sprite containers
  kill(self)
kill() end life of sprite, remove from all groups
  remove(self, group)
remove(group) remove a sprite from container
  remove_internal(self, group)
  update(self, *args)

Method Details

__init__(self, group=())
(Constructor)

__init__(group=()) initialize a sprite object

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

__new__(S, ...)

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

add(self, group)

add(group) add a sprite to container

Add the sprite to a group or sequence of groups.

alive(self)

alive() -> bool ask the life of a sprite

Returns true if this sprite is a member of any groups.

groups(self)

groups() -> list list used sprite containers

Returns a list of all the groups that contain this sprite.

kill(self)

kill() end life of sprite, remove from all groups

Removes the sprite from all the groups that contain it. The sprite is still fine after calling this kill() so you could use it to remove a sprite from all groups, and then add it to some other groups.

remove(self, group)

remove(group) remove a sprite from container

Remove the sprite from a group or sequence of groups.

Generated by Epydoc 1.1 on Sun Jan 25 19:10:08 2004 http://epydoc.sf.net