FangEngine.display_methods.sprite_sheet

This module contains the sprite sheet class for animated images

Class SpriteSheet

This class represents a single sprite sheet
Animation moves from left to right and top to bottom

__init__(self, image: str, tiles_wide: int, tiles_high: int, frames: int, speed: float = 0.1, scale_w: float = 1, scale_h: float = 1, color_key: typing.Tuple[int, int, int] = (255, 0, 255))

Parameter image: the name of the image to retrieve from the image store
Parameter tiles_wide: the number of tiles wide in the animation
Parameter tiles_high: the number of tiles high in the animation
Parameter frames: the total number of frames in the animation
For example, in a 3x3 animation, if there are only 7 frames, then set this number to 7
Parameter speed: the number of seconds to remain on each frame
Parameter scale_w: the factor to scale the image horizontally
Parameter scale_h: the factor to scale the image vertically.
While the default is 1, if None is provided, this will be set to scale_w
Parameter color_key: an RGB color to be used as the invisible color (any color not included in any of the frames)

get_current_image(self) -> Surface

Returns the current frame the animation is on

image_at(self, x: float, y: float, w: float, h: float, color_key = None) -> Surface

Returns a subsection of the image
if color_key is not set, the color key of the spritesheet will be used instead

render(self, buffer: Surface, x: float, y: float)

Draws the sprite sheet to the specified buffer at the specified location