Kivy:在动画期间更改图像

2024-09-27 04:30:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用我的代码演示物体在轨道上的运动。身体是用形象来象征的。我需要在动画期间更改图像。在方法跟踪动画中,图像的变化受参数方向的影响。移动体是可变的自我.dot我尝试将连续动画与特定动画(每个部分都有自己的图像)分开,但没有得到适用的结果。我必须在代码中添加什么?你知道吗

class Scene(FloatLayout):

    def __init__(self, **kwargs):
        super(Scene, self).__init__(**kwargs)
        pass

    def draw_scene(self):

        for i in range(0,self.count_tile):
            pos, source = self.gase.par_img(i)
            img = Image(source=source, pos=pos)
            self.add_widget(img)
            self.liTile.append(img)

        self.dot = Image(source= self.gase.tile_name[2], pos=(170,0)) # moving body
        self.add_widget(self.dot)

        return

    def on_touch_down(self, touch):
        self.gase.change_tile(touch.x, touch.y)
        self.draw_scene()
        pass

    def trace_animation(self, li_trace):
        self.animation = Animation(pos = li_trace[0], duration = 0.25)
        del li_trace[0]
        orient = 1      # parameter which influences variant of image
        for pos in li_trace:

            self.animation += Animation(pos = pos, duration = 0.25)
            orient *=-1
        self.animation.start(self.dot)

Tags: 代码pos图像selfsourceimgdeftrace

热门问题