我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用kivy.animation()。
def update(self, *args): global clocktheme temp_f_string = str(temp_f) if int(float(animation_start_time))+5 <= int(float(time_second_mod)): #animation is delayed for better asthetics if TEMPON == 1: if clocktheme == 2: # if analog clock is black, temp display is updated dynamically #comment out next line for dev work - no temp sensor connected if TempProbePresent == 1: read_temp() # If clock is shown, it goes really slow when updated dynamically self.text = temp_f_string + u'\N{DEGREE SIGN}' if TempProbePresent == 0: self.text = "--" + u'\N{DEGREE SIGN}' if clocktheme != 2: self.text = " " if TEMPON == 0: self.text = " " self.font_size = 30 self.pos = (354,140)
def animate(self, instance): animation = Animation(pos=(100, 100), t='out_bounce') animation += Animation(pos=(200, 100), t='out_bounce') animation &= Animation(size=(500, 500)) animation += Animation(size=(100, 50)) animation.start(instance) #SCHEDUALING #AUDIO
def on_touch_up(self, touch): if touch.grab_current is self: x, y = self.tpos diff_x = touch.x - x diff_y = touch.y - y space = 20 if self.backgroundscreen: # if (diff_x > space): # self.backgroundscreen.center_x = touch.x # elif (diff_x < -space): # self.backgroundscreen.center_x = touch.x if (diff_y > space): self.backgroundscreen.y = touch.y # ? ??? ??? app.game.door.door_down() # up animation self.backgroundscreen.opacity = 0 self.backgroundscreen.y = self.y anim = Animation(center_y=self.center_y, duration=.2) anim &= Animation(opacity=1, duration=.2) if anim: anim.stop(self) anim.start(self.backgroundscreen) self.backgroundcolor = random.random( ), random.random(), random.random(), .5 elif (diff_y < -space): self.backgroundscreen.y = touch.y app.game.door.door_up() # down animation self.backgroundscreen.opacity = 0 self.backgroundscreen.top = self.top anim = Animation(center_y=self.center_y, duration=.2) anim &= Animation(opacity=1, duration=.2) if anim: anim.stop(self) anim.start(self.backgroundscreen) self.backgroundcolor = random.random( ), random.random(), random.random(), .5 else: self.backgroundscreen.center_x = self.center_x self.backgroundscreen.center_y = self.center_y touch.ungrab(self)