Animation Class

Inheritance diagram of Animation

class Animation(frames)

Sequence of images with timing information.

If no frames of the animation have a duration of None, the animation loops continuously; otherwise the animation stops at the first frame with duration of None.

Variables:frames – The frames that make up the animation.

Constructor:

__init__(frames)

Create an animation directly from a list of frames.

Parameters:frames (list of AnimationFrame) – The frames that make up the animation.

Methods:

add_to_texture_bin(bin) Add the images of the animation to a TextureBin.
from_image_sequence(sequence, period[, loop]) Create an animation from a list of images and a constant framerate.
get_duration() Get the total duration of the animation in seconds.
get_max_height() Get the maximum image frame height.
get_max_width() Get the maximum image frame width.
get_transform([flip_x, flip_y, rotate]) Create a copy of this animation applying a simple transformation.

Methods

Animation.add_to_texture_bin(bin)

Add the images of the animation to a TextureBin.

The animation frames are modified in-place to refer to the texture bin regions.

Parameters:bin (TextureBin) – Texture bin to upload animation frames into.
classmethod Animation.from_image_sequence(sequence, period, loop=True)

Create an animation from a list of images and a constant framerate.

Parameters:
  • sequence (list of AbstractImage) – Images that make up the animation, in sequence.
  • period (float) – Number of seconds to display each image.
  • loop (bool) – If True, the animation will loop continuously.
Return type:

Animation

Animation.get_duration()

Get the total duration of the animation in seconds.

Return type:float
Animation.get_max_height()

Get the maximum image frame height.

This method is useful for determining texture space requirements: due to the use of anchor_y the actual required playback area may be larger.

Return type:int
Animation.get_max_width()

Get the maximum image frame width.

This method is useful for determining texture space requirements: due to the use of anchor_x the actual required playback area may be larger.

Return type:int
Animation.get_transform(flip_x=False, flip_y=False, rotate=0)

Create a copy of this animation applying a simple transformation.

The transformation is applied around the image’s anchor point of each frame. The texture data is shared between the original animation and the transformed animation.

Parameters:
  • flip_x (bool) – If True, the returned animation will be flipped horizontally.
  • flip_y (bool) – If True, the returned animation will be flipped vertically.
  • rotate (int) – Degrees of clockwise rotation of the returned animation. Only 90-degree increments are supported.
Return type:

Animation

Table Of Contents

Previous topic

AbstractImageSequence Class

Next topic

AnimationFrame Class