Class which holds information for images and animations.
This class stores images and information about how the SGE is to use those images.
What image formats are supported depends on the implementation of the SGE, but image formats that are generally a good choice are PNG and JPEG. See the implementation-specific information for a full list of supported formats.
The width of the sprite.
Note
Changing this attribute is a destructive transformation: it can result in loss of pixel information, especially if it is done repeatedly. Because of this, it is advised that you do not adjust this value for routine scaling. Use the image_xscale attribute of a sge.StellarClass object instead.
The height of the sprite.
Note
Changing this attribute is a destructive transformation: it can result in loss of pixel information, especially if it is done repeatedly. Because of this, it is advised that you do not adjust this value for routine scaling. Use the image_yscale attribute of a sge.StellarClass object instead.
Whether or not the image should be partially transparent. If an image does not have an alpha channel, a colorkey will be used, with the transparent color being the color of the top-rightmost pixel.
The suggested horizontal location of the origin relative to the left edge of the images.
The suggested vertical location of the origin relative to the top edge of the images.
The suggested rate in frames per second to animate the image at.
The suggested rate to animate the image at as a factor of sge.game.fps.
The horizontal location relative to the sprite of the suggested bounding box to use with it. If set to None, it will become equal to -origin_x (which is always the left edge of the image).
The vertical location relative to the sprite of the suggested bounding box to use with it. If set to None, it will become equal to -origin_y (which is always the top edge of the image).
The width of the suggested bounding box.
The height of the suggested bounding box.
The name of the sprite given when it was created. (Read-only)
The unique identifier of the sprite. (Read-only)
The number of animation frames in the sprite. (Read-only)
Constructor method.
Arguments:
name – The base name of the image files, used to find all individual image files that make up the sprite’s animation in the paths specified in sge.image_directories. One of the following rules will be used to find the images:
If none of the above rules can be used, IOError is raised.
ID – The value to assign id to. If set to None, name will be used, modified by the SGE if it is already the unique identifier of another sprite.
All other arguments set the respective initial attributes of the sprite. See the documentation for Sprite for more information.
Append a new blank frame to the end of the sprite.
Insert a new blank frame into the sprite.
Arguments:
Delete a frame from the sprite.
Arguments:
Draw a single-pixel dot on the sprite.
Arguments:
Draw a line segment on the sprite.
Arguments:
Draw a rectangle on the sprite.
Arguments:
Draw an ellipse on the sprite.
Arguments:
Draw a circle on the sprite.
Arguments:
Draw another sprite on the sprite.
Arguments:
sprite – The sprite to draw with.
image – The frame of sprite to draw with, where 0 is the first frame.
x – The horizontal location relative to self to position the origin of sprite.
y – The vertical location relative to self to position the origin of sprite.
frame – The frame of the sprite to draw on, where 0 is the first frame; set to None to draw on all frames.
blend_mode – The blend mode to use. Possible blend modes are:
None is treated as sge.BLEND_NORMAL.
Draw text on the sprite.
Arguments:
Erase everything from the sprite.
Arguments:
Save the sprite to an image file.
Arguments:
If the sprite has multiple frames, the image file saved will be a horizontal reel of each of the frames from left to right with no space in between the frames.
Destroy the sprite.
Note
If the sprite is being used, for example, by a sge.StellarClass object, it will not be completely destroyed until this use stops.
Return a sprite based on the tiles in a tileset.
Arguments:
For all other arguments, see the documentation for Sprite.__init__().
Each tile in the tileset becomes a subimage of the returned sprite, ordered first from left to right and then from top to bottom.
Return the current display on the screen as a sprite.
Arguments:
If you only wish to save a screenshot (of the entire screen) to a file, the easiest way to do that is:
sge.Sprite.from_screenshot().save("foo.png")