Myrmidon icon indicating copy to clipboard operation
Myrmidon copied to clipboard

Animation handling

Open Frimkron opened this issue 9 years ago • 0 comments

It would be handy if entites could handle their own animation playback, to reduce the amount of boilerplate required to increment an entity's image through a sequence each frame. The interface would be more akin to audio playback whereby there are methods to start, stop, pause, resume and change animations:

  • start_animation(anim, fps=15, loop=False) starts an animation playing and returns immediately
  • stop_animation() ends the currently playing animation
  • pause_animation() pauses the currently playing animation
  • resume_animation() continues playing a paused animation
  • change_animation(fps=15, loop=False) alters the parameters of the currently playing animation
  • is_animating() returns True if an animation is playing
  • wait_for_animation() generator that yields while an animation is playing

start_animation would be passed a sequence of images, and the entity's image property would be automatically updated asynchronously, through each image in the sequence, until the end of the animation is reached. The image would remain as the final frame of the last-played animation until it is either set to something else or another animation is started. The fps parameter would define the animation speed, in frames per second (the frame delay would be calculated using on the target fps of the game).

Frimkron avatar Feb 11 '15 23:02 Frimkron