Sprite(texture=None, shape=None, tex_shape=(0,1,1,0), ...)
This class provides a basic, four point, textured sprite.
All arguments are optional.
texture should be either the filename of an image or an OpenGL texture id. If shape is not given it will default to the dimensions of the texture if they are available. For more information on shape and tex_shape read the docstrings for Sprite.shape and Sprite.tex_shape
Additionally, you can pass values for most of the properties as keyword arguments. (x, y, xy, u, v, uv, etc...)
attrgetter(name)
Returns an anim that returns the value of the given attribute name.
(See the docs for BaseSprite.attrgetter() for more information.)
Sprite adds support for u and v, in addition to the attributes supported by BaseSprite.
convert_offset((x, y)) -> (x, y)
Converts coordinates relative to this sprite to global coordinates, including rotation and scaling.
render()
Renders the sprite onto the screen.
This method depends on the global OpenGL state. Keep that in mind if things seem to go crazy.
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
y coordinate of the bottom of the sprite
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
x coordinate of the left side of the sprite
red color component
red, green, and blue color components
red, green, blue, and alpha color components
x coordinate of the right side of the sprite
rotation
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.
The shape of the sprite.
This must either be of the form [left, top, right, bottom], or a list of four coordinates, eg. [(0,0), (20,0), (20,20), (0,20)]
[-10, -10, 10, 10] is the default.
When you assign to shape, bounding_radius is automatically set to the distance of the farthest coordinate.
This defines how a texture is mapped onto the sprite.
Like Sprite.shape, you can give either [left, top, right, bottom] or a list of coordinates.
The default is [0, 1, 1, 0], which uses the entire texture.
texture_id is a number as returned by rabbyt.load_texture(). (But you can use any loaded OpenGL texture.)
If texture_id is 0, texturing will be disabled for this sprite.
y coordinate of the top of the sprite
u texture offset
The values of u and v are added to tex_shape. This could be useful if you have multiple frames of an animation on a single texture. Set tex_shape to the shape of a single frame and set uv, to select each frame.
v texture offset
x coordinate
A tuple of the x and y coordinates
y coordinate