Animation helpers

class rapidpg.types.animation.Animated(grouping, key_function, initial_key, reset_when_switch=True)

An animated object consisted of many animations. Manage when to switch between animations and which animation to update.

Parameters:
  • grouping (dict) – A dict that maps key to Animation
  • key_function (function) – A function that decides which animation is to be displayed
  • initial_key (str) – The key to use before any calls to the key_function
  • reset_when_switch – Whether the animation should reset to the first frame when a switch happens
reset()

Call the Animation.reset() function of the current animation

update()

Call to advance the animation, or switch to another group of animation when the return value of key_function() is changed.

class rapidpg.types.animation.Animation(surfs, interval)

Store surfaces needed for animation and keep track of the current frame in the animation

Parameters:
  • surfs (sequence) – The sequence of Surfaces in the animation
  • interval (int) – The number of update() calls between switching to the next frame
reset()

Reset the animation to the first frame and reset the number of tick() calls needed to switch to the next frame

update()

Call this to advance the animation. When interval is 5 for the first 5 calls, surf will not change, on the 6th call surf is switched to the next frame

Previous topic

Image loader

Next topic

Player class

This Page