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_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().
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.
By default this is calculated from the shape property, and is automatically updated whenever the shape is updated. However, you can set it explicitly yourself.
After the value is explicitly set it will no longer be updated by changes to the shape. To revert back to the default behavior, delete the property using the del statement:
del sprite.bounding_radius
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.
x coordinate of the left side of the sprite
x coordinate of the right side of the sprite
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.
For easy integration with pyglet, a tuple with four items will be interpreted as the format used by the tex_coords attribute of pyglet textures.
y coordinate of the top of the sprite