[Python] Kivy animation - decreasing duration?

Discussão em 'Python' iniciado por Stack, Novembro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I have a widget class in kivy, which I animate on screen. By the time I want to slowly decrease animation duration so the widget will move faster. My code changes the duration, but it didn't affect on screen. Why?

    My widget class:

    class Obstacle3(Widget):
    def __init__(self, **kwargs):
    super().__init__(**kwargs)
    self.animation = Animation(x =-self.width, duration=2)
    Clock.schedule_interval(self.faster, 2)
    self.anim = True
    self.animation.bind(on_complete=self.vanish)
    self.animation.start(self)
    def faster(self, *args):
    if self.animation._duration <= 0.4:
    self.animation._duration = self.animation._duration
    else:
    self.animation._duration = self.animation._duration - 0.4

    Continue reading...

Compartilhe esta Página