I did some reading up on Aseprite. It's a nice program, and I think it might be nice to make a loader for the binary .aseprite/.ase format at some point as well. It's binary, but well defined and looks easy to parse.
In your case, it might be simplest to just subclass the Sprite module, and override the
_animate method. Here is the original method:
def _animate(self, dt):
self._frame_index += 1
if self._frame_index >= len(self._animation.frames):
self._frame_index = 0
self.dispatch_event('on_animation_end')
if self._vertex_list is None:
return # Deleted in event handler.
frame = self._animation.frames[self._frame_index]
self._set_texture(frame.image.get_texture())
if frame.duration is not None:
duration = frame.duration - (self._next_dt - dt)
duration = min(max(0, duration), frame.duration)
clock.schedule_once(self._animate, duration)
self._next_dt = duration
else:
self.dispatch_event('on_animation_end')
As you can see, it uses the duration attribute of the frames themselves to advance. I would suggest that you add a
Sprite.animation_speed property to your subclass of the
Sprite class, and then modify the
Sprite._animate method to use that value instead. This would be simple to change the speed. If you go this route, you could also easily update any frame index properties as well from within the _animate method.