tuxemon.surfanim module
- class tuxemon.surfanim.SurfaceAnimation(frames, loop=True)[source]
Bases:
object
Animation of Pygame surfaces. Starts off in the STOPPED state.
- Parameters:
frames (Sequence[Tuple[Union[str, pygame.surface.Surface], float]]) – A list of tuples (image, duration) for each frame of animation, where image can be either a Pygame surface or a path to an image, and duration is the duration in seconds. Note that the images and duration cannot be changed. A new SurfaceAnimation object will have to be created.
loop (bool) – Tells the animation object to keep playing in a loop.
- property current_frame_num: int
- property elapsed: float
- flip(flip_axes)[source]
Flip all frames of an animation along the X-axis and/or Y-axis.
- Parameters:
flip_axes (str) –
- Return type:
None
- get_frame(frame_num)[source]
Return the pygame.Surface object of the frame_num-th frame.
- Parameters:
frame_num (int) –
- Return type:
Surface
- get_rect()[source]
Returns a Rect object for this animation object.
The top and left will be set to 0, 0, and the width and height will be set to the maximum size of the animation.
- Returns:
Rect object of maximum size.
- Return type:
Rect
- property loop: bool
- pause(start_time=None)[source]
Stop having the animation progress.
- Parameters:
start_time (float | None) –
- Return type:
None
- play(start_time=None)[source]
Start playing the animation.
- Parameters:
start_time (float | None) –
- Return type:
None
- property rate: float
- property state: Literal['playing', 'paused', 'stopped']
- update(time_delta)[source]
Update the internal clock with the elapsed time.
- Parameters:
time_delta (float) – Time elapsed since last call to update.
- Return type:
None
- property visibility: bool
- class tuxemon.surfanim.SurfaceAnimationCollection(*animations)[source]
Bases:
object
- Parameters:
animations (Union[SurfaceAnimation, Sequence[SurfaceAnimation], Mapping[Any, SurfaceAnimation]]) –
- add(*animations)[source]
- Parameters:
animations (SurfaceAnimation | Sequence[SurfaceAnimation] | Mapping[Any, SurfaceAnimation]) –
- Return type:
None
- property animations: Sequence[SurfaceAnimation]
- property state: Literal['playing', 'paused', 'stopped']