BaseSprite(...)
This class provides some basic functionality for sprites:
BaseSprite doesn't render anything itself You'll want to subclass it and override either render() or render_after_transform().
You can pass any of the BaseSprite properties as keyword arguments. (x, y, xy, etc.)
attrgetter(name)
Returns an anim that returns the value of the given attribute name.
Perhaps this is easiest to see with an example. The following two lines will both do the same thing, only the second is much, much faster:
sprite.x = lambda: other_sprite.x sprite.x = other_sprite.attrgetter("x")
The anim returned by attrgetter is implemented in C and will retrieve the value without doing a python attribute lookup.
This works for any attribute that you can assign an anim to.
swizzle descriptors are propertly handled.
convert_offset((x, y)) -> (x, y)
Converts coordinates relative to this sprite to global coordinates, including rotation and scaling.
This method provides structarray integration. It shouldn't be used directly.
render()
Renders the sprite.
By default, this method will transform the OpenGL modelview matrix according to x, y, scale, and rot, and call render_after_transform().
If you want transformations to be handled for you, leave this method and override render_after_transform(). Otherwise, override render().
render_after_transform()
This method is called by BaseSprite.render() after transformations have been applied.
If you don't want to mess with doing transformations yourself, you can override this method instead of render().
bounding_radius
This should be the distance of the farthest point from the center. It can be used for collision detection.
bounding_radius_squared
This is just like bounding_radius, only it's squared. (duh)
bounding_radius and bounding_radius_squared are automatically kept in sync with each other.