From 0b516d3e3004ae73ff6ada8f0948ec9612a60ead Mon Sep 17 00:00:00 2001 From: pkor Date: Fri, 9 Aug 2013 09:20:49 -0700 Subject: [PATCH] Update animation.py --- kivy/animation.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/kivy/animation.py b/kivy/animation.py index 4a0648e1f..7de55acb5 100644 --- a/kivy/animation.py +++ b/kivy/animation.py @@ -55,7 +55,20 @@ the first half of size=(800, 800):: anim = Animation(pos=(80, 10)) anim &= Animation(size=(800, 800), duration=2.) anim.start(widget) + + +Repeating animation +------------------- +To set an animation to repeat simply set the 'repeat' value to equal 'True'. This value is 'False' by defualt. Note* this +is currently only implemented for 'sequence' animations. The following example illustrates how this can be done with a +sequential animation: + + anim = Animation(value_of_first) + Animation(value_of_second) + anim.repeat = True + anim.start(widget) + +For flow control of animations such as stopping and cancelling use the methods already in place in the animation module. ''' __all__ = ('Animation', 'AnimationTransition') @@ -344,7 +357,8 @@ class Animation(EventDispatcher): class Sequence(Animation): - + repeat = False + def __init__(self, anim1, anim2): super(Sequence, self).__init__() self.anim1 = anim1 @@ -396,7 +410,10 @@ class Sequence(Animation): self.dispatch('on_progress', widget, progress / 2.) def on_anim2_complete(self, instance, widget): - self.stop(widget) + if self.repeat == True: + self.anim1.start(widget) + else: + self.dispatch('on_complete', widget) def on_anim2_progress(self, instance, widget, progress): self.dispatch('on_progress', widget, .5 + progress / 2.)