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 properly handled.
convert_offset((x, y)) -> (x, y)
Converts coordinates relative to this sprite to global coordinates, including rotation and scaling.
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().
alpha color component
blue color component
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.
green color component
red color component
swizzle for red, green, blue
swizzle for red, green, blue, alpha
rotation angle in degrees.
scale
1.0 is normal size; 0.5 is half size, 2.0 is double size... you get the point.
You can scale the x and y axes independently by assigning a tuple with a length of two.
x component of scale
y component of scale
x coordinate of the sprite
swizzle for x, y
y coordinate of the sprite